use of meghanada.reflect.ClassIndex in project meghanada-server by mopemope.
the class ASMReflector method searchReflectInfo.
private InheritanceInfo searchReflectInfo(final Map<String, ClassIndex> index, final String name, final InheritanceInfo info) {
for (Map.Entry<String, ClassIndex> entry : index.entrySet()) {
final ClassIndex classIndex = entry.getValue();
final File file = new File(classIndex.getFilePath());
final String searchName = ClassNameUtils.removeTypeParameter(name);
final String target = classIndex.toString();
if (target.equals(searchName)) {
this.addInheritance(index, name, info, classIndex, file);
break;
}
//
final Optional<String> opt = ClassNameUtils.toInnerClassName(name);
if (opt.isPresent()) {
final String inner = opt.get();
if (target.equals(inner)) {
if (!info.classFileMap.containsKey(file)) {
info.classFileMap.put(file, new ArrayList<>(8));
}
info.inherit.add(name);
info.classFileMap.get(file).add(name);
final List<String> supers = ASMReflector.replaceSuperClassTypeParameters(name, classIndex);
Collections.reverse(supers);
supers.forEach(superClass -> {
InheritanceInfo ignored = this.searchReflectInfo(index, superClass, info);
});
break;
}
}
}
return info;
}
use of meghanada.reflect.ClassIndex in project meghanada-server by mopemope.
the class CachedASMReflector method cloneClassIndex.
private ClassIndex cloneClassIndex(ClassIndex c) {
ClassIndex ci = c.clone();
if (ci.isInnerClass()) {
String p = ci.getPackage();
if (!p.isEmpty()) {
String declaration = ci.getDisplayDeclaration();
String clazzName = declaration.substring(p.length() + 1);
ci.setName(clazzName);
}
}
return ci;
}
use of meghanada.reflect.ClassIndex in project meghanada-server by mopemope.
the class CachedASMReflector method fuzzySearchClasses.
private List<ClassIndex> fuzzySearchClasses(final String keyword, final boolean anno) {
final int length = keyword.length() + 1;
final List<ClassIndex> result = new ArrayList<>(64);
for (final ClassIndex c : this.globalClassIndex.values()) {
if (anno && !c.isAnnotation()) {
continue;
}
final String name = c.getName();
final int score = StringUtils.getFuzzyDistance(name, keyword, Locale.ENGLISH);
if (score >= length) {
result.add(cloneClassIndex(c));
}
}
return result;
}
use of meghanada.reflect.ClassIndex in project meghanada-server by mopemope.
the class ClassAnalyzeVisitor method visit.
@Override
public void visit(int api, int access, String name, String signature, String superClass, String[] interfaces) {
// log.debug("Name:{}", name);
// call class
this.access = access;
final boolean isInterface = (Opcodes.ACC_INTERFACE & access) == Opcodes.ACC_INTERFACE;
if (signature != null) {
// generics
// log.debug("name {} sig {}", name, signature);
final SignatureReader signatureReader = new SignatureReader(signature);
ClassSignatureVisitor classSignatureVisitor = new ClassSignatureVisitor(this.className, isInterface);
signatureReader.accept(classSignatureVisitor);
this.classTypeParameters = classSignatureVisitor.getTypeParameters();
this.classIndex = classSignatureVisitor.getClassIndex();
if (!this.classIndex.getSupers().contains(ClassNameUtils.OBJECT_CLASS)) {
this.classIndex.addSuper(ClassNameUtils.OBJECT_CLASS);
}
} else {
this.classTypeParameters = new ArrayList<>(4);
final List<String> supers = new ArrayList<>(4);
if (superClass != null) {
final String superClassFQCN = ClassNameUtils.replaceSlash(superClass);
supers.add(superClassFQCN);
}
Arrays.stream(interfaces).forEach(interfaceName -> supers.add(ClassNameUtils.replaceSlash(interfaceName)));
this.classIndex = new ClassIndex(this.className, new ArrayList<>(4), supers);
this.classIndex.setInterface(isInterface);
}
}
use of meghanada.reflect.ClassIndex in project meghanada-server by mopemope.
the class ClassSignatureVisitor method getClassIndex.
ClassIndex getClassIndex() {
final ClassIndex classIndex = new ClassIndex(this.getName(), this.getTypeParameters(), this.superClasses.stream().map(ClassInfo::toString).collect(Collectors.toList()));
classIndex.setInterface(this.isInterface);
return classIndex;
}
Aggregations