Search in sources :

Example 16 with MemberDescriptor

use of meghanada.reflect.MemberDescriptor in project meghanada-server by mopemope.

the class ASMReflectorTest method testReflectInterface1.

@Test
public void testReflectInterface1() throws Exception {
    ASMReflector asmReflector = ASMReflector.getInstance();
    Stopwatch stopwatch = Stopwatch.createUnstarted();
    {
        String fqcn = "com.google.common.eventbus.SubscriberExceptionHandler";
        File jar = getJar("guava");
        Map<String, ClassIndex> index = asmReflector.getClassIndexes(jar);
        final InheritanceInfo info = asmReflector.getReflectInfo(index, fqcn);
        stopwatch.start();
        List<MemberDescriptor> memberDescriptors = asmReflector.reflectAll(info);
        System.out.println(stopwatch.stop());
        memberDescriptors.forEach(m -> {
            System.out.println(m.getDeclaration());
            System.out.println("Return: " + m.getRawReturnType());
        });
        assertEquals(1, memberDescriptors.size());
        stopwatch.reset();
    }
}
Also used : AfterClass(org.junit.AfterClass) MethodDescriptor(meghanada.reflect.MethodDescriptor) BeforeClass(org.junit.BeforeClass) Assert.assertNotNull(org.junit.Assert.assertNotNull) Stopwatch(com.google.common.base.Stopwatch) ClassIndex(meghanada.reflect.ClassIndex) Config.timeIt(meghanada.config.Config.timeIt) Test(org.junit.Test) Config.debugIt(meghanada.config.Config.debugIt) File(java.io.File) MemberDescriptor(meghanada.reflect.MemberDescriptor) List(java.util.List) Map(java.util.Map) GradleTestBase(meghanada.GradleTestBase) Config(meghanada.config.Config) Assert.assertEquals(org.junit.Assert.assertEquals) Stopwatch(com.google.common.base.Stopwatch) List(java.util.List) File(java.io.File) Map(java.util.Map) Test(org.junit.Test)

Example 17 with MemberDescriptor

use of meghanada.reflect.MemberDescriptor in project meghanada-server by mopemope.

the class ASMReflectorTest method testReflectWithGenerics4.

@Test
public void testReflectWithGenerics4() throws Exception {
    ASMReflector asmReflector = ASMReflector.getInstance();
    Stopwatch stopwatch = Stopwatch.createUnstarted();
    {
        String fqcn = "com.google.common.cache.CacheBuilder<Object, Object>";
        File jar = getJar("guava");
        Map<String, ClassIndex> index = asmReflector.getClassIndexes(jar);
        final InheritanceInfo info = asmReflector.getReflectInfo(index, fqcn);
        stopwatch.start();
        List<MemberDescriptor> memberDescriptors = asmReflector.reflectAll(info);
        System.out.println(stopwatch.stop());
        memberDescriptors.forEach(m -> {
            System.out.println(m.getDeclaration());
        // System.out.println("Return: " + m.getRawReturnType());
        });
        assertEquals(61, memberDescriptors.size());
        stopwatch.reset();
    }
}
Also used : AfterClass(org.junit.AfterClass) MethodDescriptor(meghanada.reflect.MethodDescriptor) BeforeClass(org.junit.BeforeClass) Assert.assertNotNull(org.junit.Assert.assertNotNull) Stopwatch(com.google.common.base.Stopwatch) ClassIndex(meghanada.reflect.ClassIndex) Config.timeIt(meghanada.config.Config.timeIt) Test(org.junit.Test) Config.debugIt(meghanada.config.Config.debugIt) File(java.io.File) MemberDescriptor(meghanada.reflect.MemberDescriptor) List(java.util.List) Map(java.util.Map) GradleTestBase(meghanada.GradleTestBase) Config(meghanada.config.Config) Assert.assertEquals(org.junit.Assert.assertEquals) Stopwatch(com.google.common.base.Stopwatch) List(java.util.List) File(java.io.File) Map(java.util.Map) Test(org.junit.Test)

Example 18 with MemberDescriptor

use of meghanada.reflect.MemberDescriptor in project meghanada-server by mopemope.

the class ASMReflectorTest method testReflectInner2.

@Test
public void testReflectInner2() throws Exception {
    ASMReflector asmReflector = ASMReflector.getInstance();
    Stopwatch stopwatch = Stopwatch.createUnstarted();
    {
        String fqcn = "java.util.Map.Entry";
        File jar = getRTJar();
        Map<String, ClassIndex> index = asmReflector.getClassIndexes(jar);
        final InheritanceInfo info = asmReflector.getReflectInfo(index, fqcn);
        System.out.println(info);
        stopwatch.start();
        List<MemberDescriptor> memberDescriptors = asmReflector.reflectAll(info);
        System.out.println(stopwatch.stop());
        memberDescriptors.forEach(m -> System.out.println(m.getDisplayDeclaration()));
        assertEquals(18, memberDescriptors.size());
        stopwatch.reset();
    }
}
Also used : AfterClass(org.junit.AfterClass) MethodDescriptor(meghanada.reflect.MethodDescriptor) BeforeClass(org.junit.BeforeClass) Assert.assertNotNull(org.junit.Assert.assertNotNull) Stopwatch(com.google.common.base.Stopwatch) ClassIndex(meghanada.reflect.ClassIndex) Config.timeIt(meghanada.config.Config.timeIt) Test(org.junit.Test) Config.debugIt(meghanada.config.Config.debugIt) File(java.io.File) MemberDescriptor(meghanada.reflect.MemberDescriptor) List(java.util.List) Map(java.util.Map) GradleTestBase(meghanada.GradleTestBase) Config(meghanada.config.Config) Assert.assertEquals(org.junit.Assert.assertEquals) Stopwatch(com.google.common.base.Stopwatch) List(java.util.List) File(java.io.File) Map(java.util.Map) Test(org.junit.Test)

Example 19 with MemberDescriptor

use of meghanada.reflect.MemberDescriptor in project meghanada-server by mopemope.

the class ASMReflectorTest method testReflectAll5.

@Test
public void testReflectAll5() throws Exception {
    ASMReflector asmReflector = ASMReflector.getInstance();
    Stopwatch stopwatch = Stopwatch.createUnstarted();
    // Config.load().setDebug();
    {
        File jar = getRTJar();
        // Config.load().setDebug();
        String fqcn = "java.util.stream.Stream<java.util.stream.Stream<java.util.List<java.lang.String>>>";
        Map<String, ClassIndex> index = asmReflector.getClassIndexes(jar);
        final InheritanceInfo info = asmReflector.getReflectInfo(index, fqcn);
        System.out.println(info);
        stopwatch.start();
        List<MemberDescriptor> memberDescriptors1 = asmReflector.reflectAll(info);
        System.out.println(stopwatch.stop());
        System.out.println(memberDescriptors1.size());
        memberDescriptors1.forEach(md -> {
        // System.out.println(md.getDeclaration());
        // System.out.println(md.declaration);
        });
    }
}
Also used : AfterClass(org.junit.AfterClass) MethodDescriptor(meghanada.reflect.MethodDescriptor) BeforeClass(org.junit.BeforeClass) Assert.assertNotNull(org.junit.Assert.assertNotNull) Stopwatch(com.google.common.base.Stopwatch) ClassIndex(meghanada.reflect.ClassIndex) Config.timeIt(meghanada.config.Config.timeIt) Test(org.junit.Test) Config.debugIt(meghanada.config.Config.debugIt) File(java.io.File) MemberDescriptor(meghanada.reflect.MemberDescriptor) List(java.util.List) Map(java.util.Map) GradleTestBase(meghanada.GradleTestBase) Config(meghanada.config.Config) Assert.assertEquals(org.junit.Assert.assertEquals) Stopwatch(com.google.common.base.Stopwatch) List(java.util.List) File(java.io.File) Map(java.util.Map) Test(org.junit.Test)

Example 20 with MemberDescriptor

use of meghanada.reflect.MemberDescriptor in project meghanada-server by mopemope.

the class ASMReflectorTest method testReflectAll4.

@Test
public void testReflectAll4() throws Exception {
    ASMReflector asmReflector = ASMReflector.getInstance();
    Stopwatch stopwatch = Stopwatch.createUnstarted();
    {
        File jar = getRTJar();
        String fqcn = "java.util.function.Predicate";
        Map<String, ClassIndex> index = asmReflector.getClassIndexes(jar);
        final InheritanceInfo info = asmReflector.getReflectInfo(index, fqcn);
        System.out.println(info);
        stopwatch.start();
        List<MemberDescriptor> memberDescriptors = asmReflector.reflectAll(info);
        System.out.println(stopwatch.stop());
        assertEquals(16, memberDescriptors.size());
        memberDescriptors.forEach(memberDescriptor -> System.out.println(memberDescriptor.getDeclaration()));
    }
}
Also used : AfterClass(org.junit.AfterClass) MethodDescriptor(meghanada.reflect.MethodDescriptor) BeforeClass(org.junit.BeforeClass) Assert.assertNotNull(org.junit.Assert.assertNotNull) Stopwatch(com.google.common.base.Stopwatch) ClassIndex(meghanada.reflect.ClassIndex) Config.timeIt(meghanada.config.Config.timeIt) Test(org.junit.Test) Config.debugIt(meghanada.config.Config.debugIt) File(java.io.File) MemberDescriptor(meghanada.reflect.MemberDescriptor) List(java.util.List) Map(java.util.Map) GradleTestBase(meghanada.GradleTestBase) Config(meghanada.config.Config) Assert.assertEquals(org.junit.Assert.assertEquals) Stopwatch(com.google.common.base.Stopwatch) List(java.util.List) File(java.io.File) Map(java.util.Map) Test(org.junit.Test)

Aggregations

MemberDescriptor (meghanada.reflect.MemberDescriptor)26 File (java.io.File)17 Map (java.util.Map)17 ClassIndex (meghanada.reflect.ClassIndex)16 Stopwatch (com.google.common.base.Stopwatch)15 List (java.util.List)15 Config (meghanada.config.Config)15 MethodDescriptor (meghanada.reflect.MethodDescriptor)13 Test (org.junit.Test)13 GradleTestBase (meghanada.GradleTestBase)12 Config.debugIt (meghanada.config.Config.debugIt)12 Config.timeIt (meghanada.config.Config.timeIt)12 AfterClass (org.junit.AfterClass)12 Assert.assertEquals (org.junit.Assert.assertEquals)12 Assert.assertNotNull (org.junit.Assert.assertNotNull)12 BeforeClass (org.junit.BeforeClass)12 CandidateUnit (meghanada.reflect.CandidateUnit)6 CachedASMReflector (meghanada.reflect.asm.CachedASMReflector)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4