use of org.eclipse.lsp4j.TextDocumentIdentifier in project eclipse.jdt.ls by eclipse.
the class RenameHandlerTest method getRenameEdit.
private WorkspaceEdit getRenameEdit(ICompilationUnit cu, Position pos, String newName) {
TextDocumentIdentifier identifier = new TextDocumentIdentifier(JDTUtils.toURI(cu));
RenameParams params = new RenameParams(identifier, pos, newName);
return handler.rename(params, monitor);
}
use of org.eclipse.lsp4j.TextDocumentIdentifier in project eclipse.jdt.ls by eclipse.
the class ReferencesHandlerTest method testIncludeAccessors.
@Test
public void testIncludeAccessors() {
boolean includeAccessors = preferenceManager.getPreferences().isIncludeAccessors();
try {
URI uri = project.getFile("src/org/ref/Apple.java").getRawLocationURI();
String fileURI = ResourceUtils.fixURI(uri);
ReferenceParams param = new ReferenceParams();
param.setPosition(new Position(3, 18));
param.setContext(new ReferenceContext(true));
param.setTextDocument(new TextDocumentIdentifier(fileURI));
preferenceManager.getPreferences().setIncludeAccessors(false);
List<Location> references = handler.findReferences(param, monitor);
assertNotNull("findReferences should not return null", references);
assertEquals(3, references.size());
preferenceManager.getPreferences().setIncludeAccessors(true);
references = handler.findReferences(param, monitor);
assertNotNull("findReferences should not return null", references);
assertEquals(5, references.size());
Location l = references.get(0);
String refereeUri = ResourceUtils.fixURI(project.getFile("src/org/ref/Apple.java").getRawLocationURI());
assertEquals(refereeUri, l.getUri());
l = references.get(4);
refereeUri = ResourceUtils.fixURI(project.getFile("src/org/ref/Test.java").getRawLocationURI());
assertEquals(refereeUri, l.getUri());
} finally {
preferenceManager.getPreferences().setIncludeAccessors(includeAccessors);
}
}
use of org.eclipse.lsp4j.TextDocumentIdentifier in project eclipse.jdt.ls by eclipse.
the class SelectionRangeHandlerTest method getSelectionRange.
private SelectionRange getSelectionRange(String className, Position position) throws CoreException {
SelectionRangeParams params = new SelectionRangeParams();
params.setPositions(Lists.newArrayList(position));
params.setTextDocument(new TextDocumentIdentifier(ClassFileUtil.getURI(project, className)));
return new SelectionRangeHandler().selectionRange(params, monitor).get(0);
}
use of org.eclipse.lsp4j.TextDocumentIdentifier in project eclipse.jdt.ls by eclipse.
the class NavigateToDefinitionHandlerTest method testNoClassContentSupport.
@Test
public void testNoClassContentSupport() throws Exception {
when(preferenceManager.isClientSupportsClassFileContent()).thenReturn(true);
String uri = ClassFileUtil.getURI(project, "org.apache.commons.lang3.StringUtils");
when(preferenceManager.isClientSupportsClassFileContent()).thenReturn(false);
List<? extends Location> definitions = handler.definition(new TextDocumentPositionParams(new TextDocumentIdentifier(uri), new Position(20, 26)), monitor);
assertNotNull(definitions);
assertEquals(0, definitions.size());
}
use of org.eclipse.lsp4j.TextDocumentIdentifier in project eclipse.jdt.ls by eclipse.
the class NavigateToDefinitionHandlerTest method testMethodInAnonymousClass.
// https://github.com/eclipse/eclipse.jdt.ls/issues/1813
@Test
public void testMethodInAnonymousClass() throws Exception {
String className = "org.sample.App";
int line = 12;
int column = 28;
importProjects("eclipse/hello");
IProject hello = WorkspaceHelper.getProject("hello");
String uri = ClassFileUtil.getURI(hello, className);
TextDocumentIdentifier identifier = new TextDocumentIdentifier(uri);
List<? extends Location> definitions = handler.definition(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(18, definitions.get(0).getRange().getStart().getCharacter());
}
Aggregations