use of org.eclipse.jdt.ls.core.internal.handlers.FindLinksHandler.LinkLocation in project eclipse.jdt.ls by eclipse.
the class FindLinksHandlerTest method testFindSuperMethod.
@Test
public void testFindSuperMethod() throws JavaModelException {
IPackageFragment pack1 = sourceFolder.createPackageFragment("test1", false, null);
// @formatter:off
ICompilationUnit unitA = pack1.createCompilationUnit("A.java", "package test1;\n" + "\n" + "public class A {\n" + " public void run() {\n" + " }\n" + "}", true, null);
// @formatter:on
// @formatter:off
ICompilationUnit unitB = pack1.createCompilationUnit("B.java", "package test1;\n" + "\n" + "public class B extends A {\n" + " public void run() {\n" + " }\n" + "}", true, null);
// @formatter:on
String uri = JDTUtils.toURI(unitB);
List<? extends Location> response = FindLinksHandler.findLinks("superImplementation", new TextDocumentPositionParams(new TextDocumentIdentifier(uri), new Position(3, 14)), new NullProgressMonitor());
assertTrue(response != null && response.size() == 1);
LinkLocation location = (LinkLocation) response.get(0);
assertEquals("test1.A.run", location.displayName);
assertEquals("method", location.kind);
assertEquals(JDTUtils.toURI(unitA), location.getUri());
Range range = location.getRange();
assertEquals(3, range.getStart().getLine());
assertEquals(13, range.getStart().getCharacter());
assertEquals(3, range.getEnd().getLine());
assertEquals(16, range.getEnd().getCharacter());
}
use of org.eclipse.jdt.ls.core.internal.handlers.FindLinksHandler.LinkLocation in project eclipse.jdt.ls by eclipse.
the class FindLinksHandlerTest method testFindNearestSuperMethod.
@Test
public void testFindNearestSuperMethod() throws JavaModelException {
IPackageFragment pack1 = sourceFolder.createPackageFragment("test1", false, null);
// @formatter:off
ICompilationUnit unitA = pack1.createCompilationUnit("A.java", "package test1;\n" + "\n" + "public class A {\n" + " public void run() {\n" + " }\n" + "}", true, null);
// @formatter:on
// @formatter:off
ICompilationUnit unitB = pack1.createCompilationUnit("B.java", "package test1;\n" + "\n" + "public class B extends A {\n" + "}", true, null);
// @formatter:on
// @formatter:off
ICompilationUnit unitC = pack1.createCompilationUnit("C.java", "package test1;\n" + "\n" + "public class C extends B {\n" + " public void run() {\n" + " }\n" + "}", true, null);
// @formatter:on
String uri = JDTUtils.toURI(unitC);
List<? extends Location> response = FindLinksHandler.findLinks("superImplementation", new TextDocumentPositionParams(new TextDocumentIdentifier(uri), new Position(3, 14)), new NullProgressMonitor());
assertTrue(response != null && response.size() == 1);
LinkLocation location = (LinkLocation) response.get(0);
assertEquals("test1.A.run", location.displayName);
assertEquals("method", location.kind);
assertEquals(JDTUtils.toURI(unitA), location.getUri());
Range range = location.getRange();
assertEquals(3, range.getStart().getLine());
assertEquals(13, range.getStart().getCharacter());
assertEquals(3, range.getEnd().getLine());
assertEquals(16, range.getEnd().getCharacter());
}
Aggregations