Search in sources :

Example 26 with ClassIndex

use of meghanada.reflect.ClassIndex 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 27 with ClassIndex

use of meghanada.reflect.ClassIndex 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 28 with ClassIndex

use of meghanada.reflect.ClassIndex 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)

Example 29 with ClassIndex

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

the class ClassSignatureVisitorTest method testFormalType1.

@Test
public void testFormalType1() throws Exception {
    String fqcn = "java.util.Map";
    File jar = getRTJar();
    ClassSignatureVisitor visitor = doAnalyze(jar, fqcn);
    assertEquals("java.util.Map", visitor.getName());
    List<String> expected = new ArrayList<>();
    expected.add("K");
    expected.add("V");
    assertEquals(expected, visitor.getTypeParameters());
    final ClassIndex index = visitor.getClassIndex();
    System.out.println(index.isInterface());
    assertEquals(true, index.isInterface());
    assertEquals(0, index.getSupers().size());
}
Also used : ClassIndex(meghanada.reflect.ClassIndex) ArrayList(java.util.ArrayList) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 30 with ClassIndex

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

the class ClassSignatureVisitorTest method testFormalType2.

@org.junit.Test
public void testFormalType2() throws Exception {
    String fqcn = "java.util.List";
    File jar = getRTJar();
    ClassSignatureVisitor visitor = doAnalyze(jar, fqcn);
    assertEquals("java.util.List", visitor.getName());
    List<String> expected = new ArrayList<>();
    expected.add("E");
    assertEquals(expected, visitor.getTypeParameters());
    final ClassIndex index = visitor.getClassIndex();
    assertEquals(true, index.isInterface());
    assertEquals(1, index.getSupers().size());
}
Also used : ClassIndex(meghanada.reflect.ClassIndex) ArrayList(java.util.ArrayList) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Aggregations

ClassIndex (meghanada.reflect.ClassIndex)42 File (java.io.File)25 Test (org.junit.Test)22 Config (meghanada.config.Config)16 List (java.util.List)15 Map (java.util.Map)15 MemberDescriptor (meghanada.reflect.MemberDescriptor)15 Stopwatch (com.google.common.base.Stopwatch)13 GradleTestBase (meghanada.GradleTestBase)12 Config.debugIt (meghanada.config.Config.debugIt)12 Config.timeIt (meghanada.config.Config.timeIt)12 MethodDescriptor (meghanada.reflect.MethodDescriptor)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 ArrayList (java.util.ArrayList)10 CachedASMReflector (meghanada.reflect.asm.CachedASMReflector)8 JarFile (java.util.jar.JarFile)7 IOException (java.io.IOException)4