use of meghanada.reflect.ClassIndex in project meghanada-server by mopemope.
the class ASMReflectorTest method testReflectAll6.
@Test
public void testReflectAll6() throws Exception {
ASMReflector asmReflector = ASMReflector.getInstance();
Stopwatch stopwatch = Stopwatch.createUnstarted();
{
File jar = getRTJar();
Map<String, ClassIndex> index = asmReflector.getClassIndexes(jar);
String fqcn = "java.util.jar.JarFile";
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);
});
}
}
use of meghanada.reflect.ClassIndex in project meghanada-server by mopemope.
the class ASMReflectorTest method testReflectWithGenerics3.
@Test
public void testReflectWithGenerics3() throws Exception {
ASMReflector asmReflector = ASMReflector.getInstance();
Stopwatch stopwatch = Stopwatch.createUnstarted();
{
String fqcn = "java.util.Map<? extends String, ? extends Long>";
File jar = getRTJar();
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.getDisplayDeclaration()));
Config config = Config.load();
if (config.isJava8()) {
assertEquals(34, memberDescriptors.size());
} else {
assertEquals(47, memberDescriptors.size());
}
stopwatch.reset();
}
}
use of meghanada.reflect.ClassIndex in project meghanada-server by mopemope.
the class ASMReflectorTest method testGetClasses1.
@Test
public void testGetClasses1() throws Exception {
File jar = getJar("junit:junit");
ASMReflector asmReflector = ASMReflector.getInstance();
Map<ClassIndex, File> classIndex = timeIt(() -> asmReflector.getClasses(jar));
assertEquals(189, classIndex.size());
// classIndex.forEach((classIndex1, file) -> System.out.println(classIndex1));
}
use of meghanada.reflect.ClassIndex in project meghanada-server by mopemope.
the class ASMReflectorTest method testReflectWithGenerics1.
@Test
public void testReflectWithGenerics1() throws Exception {
ASMReflector asmReflector = ASMReflector.getInstance();
Stopwatch stopwatch = Stopwatch.createUnstarted();
{
String fqcn = "java.util.Map";
File jar = getRTJar();
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()));
Config config = Config.load();
if (config.isJava8()) {
assertEquals(34, memberDescriptors.size());
} else {
assertEquals(47, memberDescriptors.size());
}
stopwatch.reset();
memberDescriptors.stream().filter(memberDescriptor -> memberDescriptor.getName().equals("entrySet")).forEach(memberDescriptor -> {
if (memberDescriptor instanceof MethodDescriptor) {
MethodDescriptor methodDescriptor = (MethodDescriptor) memberDescriptor;
methodDescriptor.getTypeParameterMap().put("K", "String");
methodDescriptor.getTypeParameterMap().put("V", "Long");
System.out.println(memberDescriptor.getReturnType());
assertEquals("java.util.Set<java.util.Map$Entry<String, Long>>", memberDescriptor.getReturnType());
}
});
}
}
use of meghanada.reflect.ClassIndex in project meghanada-server by mopemope.
the class ASMReflectorTest method testReflectAll1.
@Test
public void testReflectAll1() throws Exception {
ASMReflector asmReflector = ASMReflector.getInstance();
Stopwatch stopwatch = Stopwatch.createUnstarted();
{
File jar = getRTJar();
String fqcn = "java.util.stream.Stream<java.util.List<java.lang.String>>";
Map<String, ClassIndex> index = asmReflector.getClassIndexes(jar);
final InheritanceInfo info = asmReflector.getReflectInfo(index, fqcn);
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());
});
stopwatch.reset();
stopwatch.start();
List<MemberDescriptor> memberDescriptors2 = asmReflector.reflectAll(info);
System.out.println(stopwatch.stop());
System.out.println(memberDescriptors2.size());
}
}
Aggregations