use of meghanada.analyze.Range in project meghanada-server by mopemope.
the class JavaVariableCompletionTest method createLocalVariable4.
@Test
public void createLocalVariable4() throws Exception {
JavaVariableCompletion completion = getCompilation();
Optional<LocalVariable> olv = timeIt(() -> {
final Range range = new Range(0, 0, 0, 0);
final Range nameRange = new Range(0, 0, 0, 0);
final MethodCall mc = new MethodCall("list", "subList", 0, nameRange, range);
return completion.createLocalVariable(mc, "java.util.List<MemberDescriptor>");
});
LocalVariable lv = olv.get();
System.out.println(lv);
assertEquals(6, lv.getCandidates().size());
}
use of meghanada.analyze.Range in project meghanada-server by mopemope.
the class JavaVariableCompletionTest method createLocalVariable2.
@Test
public void createLocalVariable2() throws Exception {
JavaVariableCompletion completion = getCompilation();
Optional<LocalVariable> olv = timeIt(() -> {
final Range range = new Range(0, 0, 0, 0);
final Range nameRange = new Range(0, 0, 0, 0);
final MethodCall mc = new MethodCall("file", "getFileName", 0, nameRange, range);
return completion.createLocalVariable(mc, "String");
});
LocalVariable lv = olv.get();
System.out.println(lv);
assertEquals(4, lv.getCandidates().size());
}
use of meghanada.analyze.Range in project meghanada-server by mopemope.
the class JavaVariableCompletionTest method createLocalVariable1.
@Test
public void createLocalVariable1() throws Exception {
JavaVariableCompletion completion = getCompilation();
Optional<LocalVariable> olv = debugIt(() -> {
final Range range = new Range(0, 0, 0, 0);
final Range nameRange = new Range(0, 0, 0, 0);
final MethodCall mc = new MethodCall("mkdir", 0, nameRange, range);
return completion.createLocalVariable(mc, "boolean");
});
LocalVariable lv = olv.get();
System.out.println(lv);
assertEquals(2, lv.getCandidates().size());
}
use of meghanada.analyze.Range in project meghanada-server by mopemope.
the class JavaVariableCompletionTest method createLocalVariable3.
@Test
public void createLocalVariable3() throws Exception {
JavaVariableCompletion completion = getCompilation();
Optional<LocalVariable> olv = timeIt(() -> {
final Range range = new Range(0, 0, 0, 0);
final Range nameRange = new Range(0, 0, 0, 0);
final MethodCall mc = new MethodCall("list", "subList", 0, nameRange, range);
return completion.createLocalVariable(mc, "java.util.List<String>");
});
LocalVariable lv = olv.get();
System.out.println(lv);
assertEquals(5, lv.getCandidates().size());
}
use of meghanada.analyze.Range 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;
}
Aggregations