use of meghanada.reflect.ClassIndex in project meghanada-server by mopemope.
the class ProjectDatabaseTest method testStore01.
@Test
public void testStore01() throws Exception {
String name = "java.lang.String";
ClassIndex ci = null;
int count = 10;
for (int i = 0; i < count; i++) {
ci = timeItF("store:{} count:" + i, () -> {
ClassIndex c = new ClassIndex(name, Collections.emptyList(), Collections.emptyList());
database.storeObject(c);
return c;
});
}
for (int i = 0; i < count; i++) {
ClassIndex ci2 = timeItF("load:{} count:" + i, () -> database.loadObject(ClassIndex.ENTITY_TYPE, name, ClassIndex.class));
assertEquals(ci, ci2);
}
long size = database.size(ClassIndex.ENTITY_TYPE);
assertEquals(1, size);
}
use of meghanada.reflect.ClassIndex in project meghanada-server by mopemope.
the class ProjectDatabaseTest method testStore02.
@Test
public void testStore02() throws Exception {
String name = "java.lang.String";
ClassIndex ci = null;
int count = 100;
for (int i = 0; i < count; i++) {
ci = timeItF("store:{} count:" + i, () -> {
ClassIndex c = new ClassIndex(name, Collections.emptyList(), Collections.emptyList());
database.storeObject(c, false);
return c;
});
}
for (int i = 0; i < count; i++) {
ClassIndex ci2 = timeItF("load:{} count:" + i, () -> database.loadObject(ClassIndex.ENTITY_TYPE, name, ClassIndex.class));
assertEquals(ci, ci2);
}
long size = database.size(ClassIndex.ENTITY_TYPE);
assertEquals(1, size);
}
use of meghanada.reflect.ClassIndex in project meghanada-server by mopemope.
the class ProjectDatabaseTest method testStore03.
@Test
public void testStore03() throws Exception {
String name = "java.lang.String";
ClassIndex ci = null;
int count = 100;
List<ClassIndex> lst = new ArrayList<>();
for (int i = 0; i < count; i++) {
ClassIndex c = new ClassIndex(name + i, Collections.emptyList(), Collections.emptyList());
lst.add(c);
}
database.storeObjects(lst, true);
lst.forEach(c -> {
System.out.println(c.getEntityId());
});
}
use of meghanada.reflect.ClassIndex 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();
}
}
use of meghanada.reflect.ClassIndex 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();
}
}
Aggregations