use of meghanada.analyze.Position in project meghanada-server by mopemope.
the class ReferenceSearcher method searchMemberCondition.
private static Optional<SearchCondition> searchMemberCondition(Source source, int line, int col, String symbol) {
EntryMessage msg = log.traceEntry("line={} col={} symbol={}", line, col, symbol);
for (ClassScope classScope : source.getClassScopes()) {
for (Variable variable : classScope.getVariables()) {
if (variable.isField) {
Position pos = variable.range.begin;
String name = variable.name;
if (pos.line == line && name.equals(symbol)) {
String clazz = classScope.getFQCN();
SearchCondition condition = new SearchCondition(clazz, name, SearchCondition.Type.FIELD);
return Optional.of(condition);
}
}
}
for (BlockScope blockScope : classScope.getScopes()) {
if (blockScope instanceof MethodScope) {
MethodScope methodScope = ((MethodScope) blockScope);
Position pos = methodScope.getNameRange().begin;
String name = methodScope.getName();
if (pos.line == line && name.equals(symbol)) {
String clazz = classScope.getFQCN();
SearchCondition condition = new SearchCondition(clazz, name, SearchCondition.Type.METHOD, methodScope.getParameters());
return Optional.of(condition);
}
}
}
}
log.traceExit(msg);
return Optional.empty();
}
Aggregations