use of org.eclipse.xtext.xbase.lib.Extension in project xtext-core by eclipse.
the class CommandServiceTest method testExecuteCommand.
protected void testExecuteCommand(final Procedure1<? super CommandServiceTest.TestExecuteCommandConfiguration> configurator) {
try {
@Extension final CommandServiceTest.TestExecuteCommandConfiguration configuration = new CommandServiceTest.TestExecuteCommandConfiguration();
configurator.apply(configuration);
final String command = configuration.command;
final List<Object> args = configuration.args;
ExecuteCommandParams _executeCommandParams = new ExecuteCommandParams(command, args);
final CompletableFuture<Object> result = this.languageServer.executeCommand(_executeCommandParams);
if ((configuration.assertCommandResult != null)) {
final Object value = result.get();
configuration.assertCommandResult.accept(value);
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.xbase.lib.Extension in project xtext-core by eclipse.
the class AbstractLanguageServerTest method testCodeAction.
protected void testCodeAction(final Procedure1<? super AbstractLanguageServerTest.TestCodeActionConfiguration> configurator) {
try {
@Extension final AbstractLanguageServerTest.TestCodeActionConfiguration configuration = new AbstractLanguageServerTest.TestCodeActionConfiguration();
configuration.setFilePath(("MyModel." + this.fileExtension));
configurator.apply(configuration);
final String filePath = this.initializeContext(configuration).getUri();
CodeActionParams _codeActionParams = new CodeActionParams();
final Procedure1<CodeActionParams> _function = (CodeActionParams it) -> {
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(filePath);
it.setTextDocument(_textDocumentIdentifier);
CodeActionContext _codeActionContext = new CodeActionContext();
final Procedure1<CodeActionContext> _function_1 = (CodeActionContext it_1) -> {
it_1.setDiagnostics(this.getDiagnostics().get(filePath));
};
CodeActionContext _doubleArrow = ObjectExtensions.<CodeActionContext>operator_doubleArrow(_codeActionContext, _function_1);
it.setContext(_doubleArrow);
};
CodeActionParams _doubleArrow = ObjectExtensions.<CodeActionParams>operator_doubleArrow(_codeActionParams, _function);
final CompletableFuture<List<? extends Command>> codeLenses = this.languageServer.codeAction(_doubleArrow);
if ((configuration.assertCodeActions != null)) {
configuration.assertCodeActions.apply(codeLenses.get());
} else {
this.assertEquals(configuration.expectedCodeActions, this.toExpectation(codeLenses.get()));
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.xbase.lib.Extension in project xtext-core by eclipse.
the class AbstractLanguageServerTest method testSignatureHelp.
protected void testSignatureHelp(final Procedure1<? super SignatureHelpConfiguration> configurator) {
try {
@Extension final SignatureHelpConfiguration configuration = new SignatureHelpConfiguration();
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<SignatureHelp> signatureHelpFuture = this.languageServer.signatureHelp(_doubleArrow);
final SignatureHelp signatureHelp = signatureHelpFuture.get();
Procedure1<? super SignatureHelp> _assertSignatureHelp = configuration.getAssertSignatureHelp();
boolean _tripleNotEquals = (_assertSignatureHelp != null);
if (_tripleNotEquals) {
configuration.getAssertSignatureHelp().apply(signatureHelp);
} else {
final String actualSignatureHelp = this.toExpectation(signatureHelp);
this.assertEquals(configuration.getExpectedSignatureHelp().trim(), actualSignatureHelp.trim());
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.xbase.lib.Extension 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.xtext.xbase.lib.Extension in project xtext-core by eclipse.
the class AbstractLanguageServerTest method testCodeLens.
protected void testCodeLens(final Procedure1<? super AbstractLanguageServerTest.TestCodeLensConfiguration> configurator) {
try {
@Extension final AbstractLanguageServerTest.TestCodeLensConfiguration configuration = new AbstractLanguageServerTest.TestCodeLensConfiguration();
configuration.setFilePath(("MyModel." + this.fileExtension));
configurator.apply(configuration);
final String filePath = this.initializeContext(configuration).getUri();
CodeLensParams _codeLensParams = new CodeLensParams();
final Procedure1<CodeLensParams> _function = (CodeLensParams it) -> {
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(filePath);
it.setTextDocument(_textDocumentIdentifier);
};
CodeLensParams _doubleArrow = ObjectExtensions.<CodeLensParams>operator_doubleArrow(_codeLensParams, _function);
final CompletableFuture<List<? extends CodeLens>> codeLenses = this.languageServer.codeLens(_doubleArrow);
final Function1<CodeLens, CodeLens> _function_1 = (CodeLens it) -> {
try {
return this.languageServer.resolveCodeLens(it).get();
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
};
final List<CodeLens> result = IterableExtensions.<CodeLens>toList(ListExtensions.map(codeLenses.get(), _function_1));
if ((configuration.assertCodeLenses != null)) {
configuration.assertCodeLenses.apply(result);
} else {
this.assertEquals(configuration.expectedCodeLensItems, this.toExpectation(result));
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations