use of org.eclipse.xtext.testing.DefinitionTestConfiguration in project xtext-core by eclipse.
the class AbstractLanguageServerTest method testDefinition.
protected void testDefinition(final Procedure1<? super DefinitionTestConfiguration> configurator) {
try {
@Extension final DefinitionTestConfiguration configuration = new DefinitionTestConfiguration();
configuration.setFilePath(("MyModel." + this.fileExtension));
configurator.apply(configuration);
final String fileUri = this.initializeContext(configuration).getUri();
TextDocumentPositionParams _textDocumentPositionParams = new TextDocumentPositionParams();
final Procedure1<TextDocumentPositionParams> _function = (TextDocumentPositionParams 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);
};
TextDocumentPositionParams _doubleArrow = ObjectExtensions.<TextDocumentPositionParams>operator_doubleArrow(_textDocumentPositionParams, _function);
final CompletableFuture<List<? extends Location>> definitionsFuture = this.languageServer.definition(_doubleArrow);
final List<? extends Location> definitions = definitionsFuture.get();
Procedure1<? super List<? extends Location>> _assertDefinitions = configuration.getAssertDefinitions();
boolean _tripleNotEquals = (_assertDefinitions != null);
if (_tripleNotEquals) {
configuration.getAssertDefinitions().apply(definitions);
} else {
final String actualDefinitions = this.toExpectation(definitions);
this.assertEquals(configuration.getExpectedDefinitions(), actualDefinitions);
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.testing.DefinitionTestConfiguration in project xtext-core by eclipse.
the class DefinitionTest method testDefinition_01.
@Test
public void testDefinition_01() {
final Procedure1<DefinitionTestConfiguration> _function = (DefinitionTestConfiguration it) -> {
StringConcatenation _builder = new StringConcatenation();
_builder.append("type Foo {}");
_builder.newLine();
_builder.append("type Bar {");
_builder.newLine();
_builder.append("\t");
_builder.append("Foo foo");
_builder.newLine();
_builder.append("}");
_builder.newLine();
it.setModel(_builder.toString());
it.setLine(2);
it.setColumn(3);
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("MyModel.testlang [[0, 5] .. [0, 8]]");
_builder_1.newLine();
it.setExpectedDefinitions(_builder_1.toString());
};
this.testDefinition(_function);
}
Aggregations