use of meghanada.analyze.FieldAccess in project meghanada-server by mopemope.
the class ReferenceSearcher method searchFieldReferences.
private static List<Reference> searchFieldReferences(Source src, SearchCondition sc) throws IOException {
List<String> lines = FileUtils.readLines(src.getFile());
int size = lines.size();
List<Reference> result = new ArrayList<>(size);
Collection<FieldAccess> fieldAccesses = src.getFieldAccesses();
for (FieldAccess fa : fieldAccesses) {
String declaringClass = fa.declaringClass;
String methodName = fa.name;
if (sc.declaringClass.equals(declaringClass) && sc.name.equals(methodName)) {
Range range = fa.range;
long line = range.begin.line;
long column = range.begin.column;
String code = StringEscapeUtils.escapeJava(lines.get((int) line - 1));
Reference ref = new Reference(src.filePath, line, column, code);
result.add(ref);
}
}
return result;
}
use of meghanada.analyze.FieldAccess in project meghanada-server by mopemope.
the class ReferenceSearcher method searchClassReferences.
private static List<Reference> searchClassReferences(Source src, SearchCondition sc) throws IOException {
List<String> lines = FileUtils.readLines(src.getFile());
int size = lines.size();
List<Reference> result = new ArrayList<>(size);
Collection<MethodCall> methodCalls = src.getMethodCalls();
for (MethodCall mc : methodCalls) {
String declaringClass = mc.declaringClass;
if (sc.declaringClass.equals(declaringClass) && mc.scope.contains(sc.name)) {
Range range = mc.nameRange;
long line = range.begin.line;
long column = range.begin.column;
String code = StringEscapeUtils.escapeJava(lines.get((int) line - 1));
Reference ref = new Reference(src.filePath, line, column, code);
result.add(ref);
}
}
Collection<FieldAccess> fieldAccesses = src.getFieldAccesses();
for (FieldAccess fa : fieldAccesses) {
String declaringClass = fa.declaringClass;
if (sc.declaringClass.equals(declaringClass) && fa.scope.contains(sc.name)) {
Range range = fa.range;
long line = range.begin.line;
long column = range.begin.column;
String code = StringEscapeUtils.escapeJava(lines.get((int) line - 1));
Reference ref = new Reference(src.filePath, line, column, code);
result.add(ref);
}
}
return result;
}
Aggregations