use of meghanada.reflect.ClassIndex in project meghanada-server by mopemope.
the class ReferenceSearcher method searchClassCondition.
private static Optional<SearchCondition> searchClassCondition(Source source, int line, int col, String symbol) {
final CachedASMReflector reflector = CachedASMReflector.getInstance();
final EntryMessage entryMessage = log.traceEntry("line={} col={} symbol={}", line, col, symbol);
Optional<SearchCondition> result;
String fqcn = source.getImportedClassFQCN(symbol, null);
if (isNull(fqcn)) {
if (!source.getPackageName().isEmpty()) {
fqcn = source.getPackageName() + '.' + symbol;
result = reflector.containsClassIndex(fqcn).map(index -> {
SearchCondition sc = new SearchCondition(index.getRawDeclaration(), index.getName(), SearchCondition.Type.CLASS);
return Optional.of(sc);
}).orElseGet(() -> {
final Set<String> parents = new HashSet<>(8);
for (final ClassScope classScope : source.getClassScopes()) {
final String className = classScope.getFQCN();
parents.add(className);
}
parents.addAll(source.importClasses);
for (final ClassIndex index : reflector.searchInnerClasses(parents)) {
final String returnType = index.getReturnType();
if (returnType.endsWith(symbol)) {
SearchCondition sc = new SearchCondition(index.getRawDeclaration(), index.getName(), SearchCondition.Type.CLASS);
return Optional.of(sc);
}
}
return Optional.empty();
});
} else {
result = Optional.empty();
}
} else {
SearchCondition sc = new SearchCondition(fqcn, ClassNameUtils.getSimpleName(fqcn), SearchCondition.Type.CLASS);
result = Optional.of(sc);
}
log.traceExit(entryMessage);
return result;
}
use of meghanada.reflect.ClassIndex in project meghanada-server by mopemope.
the class MemberCacheLoader method getClassFile.
private static File getClassFile(String fqcn) {
Map<String, ClassIndex> globalClassIndex = CachedASMReflector.getInstance().getGlobalClassIndex();
ClassIndex classIndex = globalClassIndex.get(fqcn);
if (nonNull(classIndex)) {
String filePath = classIndex.getFilePath();
if (nonNull(filePath)) {
return new File(filePath);
}
}
return null;
}
Aggregations