use of org.eclipse.lsp4j.Position 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.Position in project eclipse.jdt.ls by eclipse.
the class SelectionRangeHandlerTest method testSwitch.
@Test
public void testSwitch() throws CoreException {
SelectionRange range = getSelectionRange("org.sample.Foo4", new Position(22, 27));
assertTrue(validateSelectionRange(// simple name
range, // simple name
new Range(new Position(22, 24), new Position(22, 30)), // method invocation
new Range(new Position(22, 5), new Position(22, 31)), // expression statement
new Range(new Position(22, 5), new Position(22, 32)), // switch statement
new Range(new Position(20, 3), new Position(26, 4)), // block
new Range(new Position(19, 6), new Position(27, 3)), // try statement
new Range(new Position(19, 2), new Position(29, 3)), // block
new Range(new Position(18, 85), new Position(30, 2)), // method declaration
new Range(new Position(18, 1), new Position(30, 2)), TYPE_DECL_RANGE, COMP_UNIT_RAGE));
}
use of org.eclipse.lsp4j.Position in project eclipse.jdt.ls by eclipse.
the class SelectionRangeHandlerTest method testParamList.
@Test
public void testParamList() throws CoreException {
SelectionRange range = getSelectionRange("org.sample.Foo4", new Position(18, 24));
assertTrue(validateSelectionRange(// simple name
range, // simple name
new Range(new Position(18, 21), new Position(18, 27)), // single variable declaration
new Range(new Position(18, 17), new Position(18, 27)), // method declaration
new Range(new Position(18, 1), new Position(30, 2)), TYPE_DECL_RANGE, COMP_UNIT_RAGE));
}
use of org.eclipse.lsp4j.Position in project eclipse.jdt.ls by eclipse.
the class SelectionRangeHandlerTest method testStringLiteral.
@Test
public void testStringLiteral() throws CoreException {
SelectionRange range = getSelectionRange("org.sample.Foo4", new Position(12, 30));
assertTrue(validateSelectionRange(// string literal
range, // string literal
new Range(new Position(12, 21), new Position(12, 40)), // method invocation
new Range(new Position(12, 2), new Position(12, 41)), // expression statement
new Range(new Position(12, 2), new Position(12, 42)), // block
new Range(new Position(11, 8), new Position(16, 2)), // method declaration
new Range(new Position(8, 1), new Position(16, 2)), TYPE_DECL_RANGE, COMP_UNIT_RAGE));
}
use of org.eclipse.lsp4j.Position 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());
}
Aggregations