use of org.eclipse.lsp4j.Position in project eclipse.jdt.ls by eclipse.
the class CallHierarchyHandler method callHierarchyOutgoingCalls.
public List<CallHierarchyOutgoingCall> callHierarchyOutgoingCalls(CallHierarchyOutgoingCallsParams params, IProgressMonitor monitor) {
Assert.isNotNull(params, "params");
CallHierarchyItem item = params.getItem();
Assert.isNotNull(item, "call item");
Position position = item.getRange().getStart();
int line = position.getLine();
int character = position.getCharacter();
try {
return getOutgoingCallItemsAt(item.getUri(), line, character, monitor);
} catch (JavaModelException e) {
JavaLanguageServerPlugin.log(e);
} catch (OperationCanceledException e) {
// do nothing
}
return null;
}
use of org.eclipse.lsp4j.Position in project eclipse.jdt.ls by eclipse.
the class TypeHierarchyCommandTest method testSubTypeHierarchy.
@Test
public void testSubTypeHierarchy() throws Exception {
IProgressMonitor monitor = new NullProgressMonitor();
TypeHierarchyParams params = new TypeHierarchyParams();
String uriString = fJProject.getFile("src/main/java/org/sample/CallHierarchy.java").getLocationURI().toString();
TextDocumentIdentifier identifier = new TextDocumentIdentifier(uriString);
Position position = new Position(2, 43);
params.setTextDocument(identifier);
params.setResolve(2);
params.setDirection(TypeHierarchyDirection.Children);
params.setPosition(position);
TypeHierarchyItem item = fCommand.typeHierarchy(params, monitor);
assertNotNull(item);
assertEquals(item.getName(), "Builder");
assertNull(item.getParents());
assertEquals(item.getChildren().size(), 9);
for (TypeHierarchyItem child : item.getChildren()) {
List<TypeHierarchyItem> subChild = child.getChildren();
assertNotNull(subChild);
if (subChild.size() == 1) {
assertEquals(subChild.get(0).getName(), "ReflectionToStringBuilder");
}
}
}
use of org.eclipse.lsp4j.Position in project eclipse.jdt.ls by eclipse.
the class JSONUtilityTest method testJsonElementToObject.
@Test
public void testJsonElementToObject() {
Gson gson = new Gson();
Position position = new Position(5, 5);
JsonElement element = gson.toJsonTree(position);
Position position2 = JSONUtility.toModel(element, Position.class);
assertEquals(position, position2);
}
use of org.eclipse.lsp4j.Position in project eclipse.jdt.ls by eclipse.
the class JSONUtilityTest method testObjectToObject.
@Test
public void testObjectToObject() {
Position position = new Position(5, 5);
Position position2 = JSONUtility.toModel(position, Position.class);
assertSame(position, position2);
}
use of org.eclipse.lsp4j.Position in project eclipse.jdt.ls by eclipse.
the class AssignToVariableRefactorTest method testAssignStatementToField.
@Test
public void testAssignStatementToField() throws Exception {
setIgnoredCommands("Assign statement to new local variable", ActionMessages.GenerateConstructorsAction_ellipsisLabel, ActionMessages.GenerateConstructorsAction_label);
IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null);
StringBuilder buf = new StringBuilder();
buf.append("package test1;\n");
buf.append("public class E {\n");
buf.append(" public static void main(String[] args) {\n");
buf.append(" E test = new E();\n");
buf.append(" test.foo();\n");
buf.append(" }\n");
buf.append(" public int foo() {\n");
buf.append(" return 1;\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);
Range range = new Range(new Position(4, 10), new Position(4, 10));
testAssignField(cu, range);
range = new Range(new Position(4, 15), new Position(4, 15));
testAssignField(cu, range);
}
Aggregations