Search in sources :

Example 6 with CallHierarchyItem

use of org.eclipse.lsp4j.CallHierarchyItem in project eclipse.jdt.ls by eclipse.

the class CallHierarchyHandlerTest method testSelectionRange.

@Test
public void testSelectionRange() throws Exception {
    // Line  from `org.sample.Foo`
    // public void <|>someMethod() {}
    String uri = getUriFromSrcProject("org.sample.Foo");
    List<CallHierarchyItem> items = prepareCallHierarchy(uri, 8, 13);
    assertNotNull(items);
    assertEquals(1, items.size());
    assertItem(items.get(0), "someMethod()" + JavaElementLabels.DECL_STRING + "void", Method, "org.sample.Foo", false, 8);
    List<CallHierarchyIncomingCall> calls = getIncomingCalls(items.get(0));
    assertNotNull(calls);
    assertEquals(4, calls.size());
    assertItem(calls.get(2).getFrom(), "main(String[]) : void", Method, "org.sample.Call", false, 7);
    assertItem(calls.get(3).getFrom(), "main(String[]) : void", Method, "org.sample.Call", false, 10);
    Range selectionRange = calls.get(2).getFrom().getSelectionRange();
    assertEquals(new Range(new Position(7, 18), new Position(7, 30)), selectionRange);
    selectionRange = calls.get(3).getFrom().getSelectionRange();
    assertEquals(new Range(new Position(10, 18), new Position(10, 30)), selectionRange);
}
Also used : CallHierarchyIncomingCall(org.eclipse.lsp4j.CallHierarchyIncomingCall) Position(org.eclipse.lsp4j.Position) CallHierarchyItem(org.eclipse.lsp4j.CallHierarchyItem) Range(org.eclipse.lsp4j.Range) AbstractProjectsManagerBasedTest(org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest) Test(org.junit.Test)

Aggregations

CallHierarchyItem (org.eclipse.lsp4j.CallHierarchyItem)6 Range (org.eclipse.lsp4j.Range)4 CallLocation (org.eclipse.jdt.internal.corext.callhierarchy.CallLocation)3 Position (org.eclipse.lsp4j.Position)3 ArrayList (java.util.ArrayList)2 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)2 SubMonitor (org.eclipse.core.runtime.SubMonitor)2 IMember (org.eclipse.jdt.core.IMember)2 JavaModelException (org.eclipse.jdt.core.JavaModelException)2 MethodWrapper (org.eclipse.jdt.internal.corext.callhierarchy.MethodWrapper)2 CallHierarchyIncomingCall (org.eclipse.lsp4j.CallHierarchyIncomingCall)2 IOpenable (org.eclipse.jdt.core.IOpenable)1 IType (org.eclipse.jdt.core.IType)1 AbstractProjectsManagerBasedTest (org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest)1 CallHierarchyOutgoingCall (org.eclipse.lsp4j.CallHierarchyOutgoingCall)1 Location (org.eclipse.lsp4j.Location)1 Test (org.junit.Test)1