use of org.eclipse.lsp4j.ReferenceContext in project eclipse.jdt.ls by eclipse.
the class ReferencesHandlerTest method testEmpty.
@Test
public void testEmpty() {
ReferenceParams param = new ReferenceParams();
param.setPosition(new Position(1, 1));
param.setContext(new ReferenceContext(false));
param.setTextDocument(new TextDocumentIdentifier("/foo/bar"));
List<Location> references = handler.findReferences(param, monitor);
assertNotNull(references);
assertTrue("references are not empty", references.isEmpty());
}
use of org.eclipse.lsp4j.ReferenceContext in project xtext-core by eclipse.
the class AbstractLanguageServerTest method testReferences.
protected void testReferences(final Procedure1<? super ReferenceTestConfiguration> configurator) {
try {
@Extension final ReferenceTestConfiguration configuration = new ReferenceTestConfiguration();
configuration.setFilePath(("MyModel." + this.fileExtension));
configurator.apply(configuration);
final String fileUri = this.initializeContext(configuration).getUri();
ReferenceParams _referenceParams = new ReferenceParams();
final Procedure1<ReferenceParams> _function = (ReferenceParams it) -> {
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(fileUri);
it.setTextDocument(_textDocumentIdentifier);
int _line = configuration.getLine();
int _column = configuration.getColumn();
Position _position = new Position(_line, _column);
it.setPosition(_position);
boolean _isIncludeDeclaration = configuration.isIncludeDeclaration();
ReferenceContext _referenceContext = new ReferenceContext(_isIncludeDeclaration);
it.setContext(_referenceContext);
};
ReferenceParams _doubleArrow = ObjectExtensions.<ReferenceParams>operator_doubleArrow(_referenceParams, _function);
final CompletableFuture<List<? extends Location>> referencesFuture = this.languageServer.references(_doubleArrow);
final List<? extends Location> references = referencesFuture.get();
Procedure1<? super List<? extends Location>> _assertReferences = configuration.getAssertReferences();
boolean _tripleNotEquals = (_assertReferences != null);
if (_tripleNotEquals) {
configuration.getAssertReferences().apply(references);
} else {
final String actualReferences = this.toExpectation(references);
this.assertEquals(configuration.getExpectedReferences(), actualReferences);
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.lsp4j.ReferenceContext in project eclipse.jdt.ls by eclipse.
the class ReferencesHandlerTest method testReference.
@Test
public void testReference() {
URI uri = project.getFile("src/java/Foo2.java").getRawLocationURI();
String fileURI = ResourceUtils.fixURI(uri);
ReferenceParams param = new ReferenceParams();
param.setPosition(new Position(5, 16));
param.setContext(new ReferenceContext(true));
param.setTextDocument(new TextDocumentIdentifier(fileURI));
List<Location> references = handler.findReferences(param, monitor);
assertNotNull("findReferences should not return null", references);
assertEquals(1, references.size());
Location l = references.get(0);
String refereeUri = ResourceUtils.fixURI(project.getFile("src/java/Foo3.java").getRawLocationURI());
assertEquals(refereeUri, l.getUri());
}
Aggregations