use of org.eclipse.lsp4j.TextDocumentIdentifier in project eclipse.jdt.ls by eclipse.
the class ImplementationsHandlerTest method testEmpty.
@Test
public void testEmpty() {
TextDocumentPositionParams param = new TextDocumentPositionParams();
param.setPosition(new Position(1, 1));
param.setTextDocument(new TextDocumentIdentifier("/foo/bar"));
List<? extends Location> implementations = handler.findImplementations(param, monitor);
assertNotNull(implementations);
assertTrue("implementations are not empty", implementations.isEmpty());
}
use of org.eclipse.lsp4j.TextDocumentIdentifier in project eclipse.jdt.ls by eclipse.
the class ImplementationsHandlerTest method testMethodInvocationImplementation.
@Test
public void testMethodInvocationImplementation() {
URI uri = project.getFile("src/org/sample/FooService.java").getRawLocationURI();
String fileURI = ResourceUtils.fixURI(uri);
TextDocumentPositionParams param = new TextDocumentPositionParams();
// Position over foo.someMethod
param.setPosition(new Position(6, 14));
param.setTextDocument(new TextDocumentIdentifier(fileURI));
List<? extends Location> implementations = handler.findImplementations(param, monitor);
assertNotNull("findImplementations should not return null", implementations);
assertEquals(implementations.toString(), 1, implementations.size());
Location foo2 = implementations.get(0);
assertTrue("Unexpected implementation : " + foo2.getUri(), foo2.getUri().contains("org/sample/Foo2.java"));
// check range points to someMethod() position
assertEquals(new Position(4, 16), foo2.getRange().getStart());
assertEquals(new Position(4, 26), foo2.getRange().getEnd());
}
use of org.eclipse.lsp4j.TextDocumentIdentifier in project eclipse.jdt.ls by eclipse.
the class NavigateToTypeDefinitionHandlerTest method testGetEmptyDefinition.
@Test
public void testGetEmptyDefinition() throws Exception {
List<? extends Location> definitions = handler.typeDefinition(new TextDocumentPositionParams(new TextDocumentIdentifier("/foo/bar"), new Position(1, 1)), monitor);
assertNull(definitions);
}
use of org.eclipse.lsp4j.TextDocumentIdentifier in project eclipse.jdt.ls by eclipse.
the class NavigateToTypeDefinitionHandlerTest method testDisassembledSource.
@Test
public void testDisassembledSource() throws JavaModelException {
String className = "javax.tools.Tool";
int line = 6;
int column = 57;
String uri = ClassFileUtil.getURI(project, className);
TextDocumentIdentifier identifier = new TextDocumentIdentifier(uri);
List<? extends Location> definitions = handler.typeDefinition(new TextDocumentPositionParams(identifier, new Position(line, column)), monitor);
assertNotNull(definitions);
assertEquals("No definition found for " + className, 1, definitions.size());
assertNotNull(definitions.get(0).getUri());
assertEquals(3, definitions.get(0).getRange().getStart().getLine());
assertEquals(12, definitions.get(0).getRange().getStart().getCharacter());
}
use of org.eclipse.lsp4j.TextDocumentIdentifier in project eclipse.jdt.ls by eclipse.
the class NavigateToTypeDefinitionHandlerTest method testClass.
private void testClass(String className, int line, int column) throws JavaModelException {
String uri = ClassFileUtil.getURI(project, className);
TextDocumentIdentifier identifier = new TextDocumentIdentifier(uri);
List<? extends Location> definitions = handler.typeDefinition(new TextDocumentPositionParams(identifier, new Position(line, column)), monitor);
assertNotNull(definitions);
assertEquals("No definition found for " + className, 1, definitions.size());
assertNotNull(definitions.get(0).getUri());
assertTrue(definitions.get(0).getRange().getStart().getLine() >= 0);
}
Aggregations