use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-core by eclipse.
the class CodeLensService method computeCodeLenses.
@Override
public List<? extends CodeLens> computeCodeLenses(final Document document, final XtextResource resource, final CodeLensParams params, final CancelIndicator indicator) {
CodeLens _codeLens = new CodeLens();
final Procedure1<CodeLens> _function = (CodeLens it) -> {
Command _command = new Command();
final Procedure1<Command> _function_1 = (Command it_1) -> {
it_1.setCommand("do.this");
it_1.setTitle("Do Awesome Stuff");
it_1.setArguments(Collections.<Object>unmodifiableList(CollectionLiterals.<Object>newArrayList("foo", Integer.valueOf(1), Boolean.valueOf(true))));
};
Command _doubleArrow = ObjectExtensions.<Command>operator_doubleArrow(_command, _function_1);
it.setCommand(_doubleArrow);
Position _position = new Position(1, 2);
it.setData(_position);
};
CodeLens _doubleArrow = ObjectExtensions.<CodeLens>operator_doubleArrow(_codeLens, _function);
return Collections.<CodeLens>unmodifiableList(CollectionLiterals.<CodeLens>newArrayList(_doubleArrow));
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-core by eclipse.
the class CommandRegistryTest method testRegistration.
@Test
public void testRegistration() {
final ExecutableCommandRegistry reg = new ExecutableCommandRegistry();
ClientCapabilities _clientCapabilities = new ClientCapabilities();
final Procedure1<ClientCapabilities> _function = (ClientCapabilities it) -> {
WorkspaceClientCapabilities _workspaceClientCapabilities = new WorkspaceClientCapabilities();
final Procedure1<WorkspaceClientCapabilities> _function_1 = (WorkspaceClientCapabilities it_1) -> {
ExecuteCommandCapabilities _executeCommandCapabilities = new ExecuteCommandCapabilities();
final Procedure1<ExecuteCommandCapabilities> _function_2 = (ExecuteCommandCapabilities it_2) -> {
it_2.setDynamicRegistration(Boolean.valueOf(true));
};
ExecuteCommandCapabilities _doubleArrow = ObjectExtensions.<ExecuteCommandCapabilities>operator_doubleArrow(_executeCommandCapabilities, _function_2);
it_1.setExecuteCommand(_doubleArrow);
};
WorkspaceClientCapabilities _doubleArrow = ObjectExtensions.<WorkspaceClientCapabilities>operator_doubleArrow(_workspaceClientCapabilities, _function_1);
it.setWorkspace(_doubleArrow);
};
final ClientCapabilities cap = ObjectExtensions.<ClientCapabilities>operator_doubleArrow(_clientCapabilities, _function);
reg.initialize(Collections.<IResourceServiceProvider>unmodifiableList(CollectionLiterals.<IResourceServiceProvider>newArrayList(this)), cap, this);
Assert.assertEquals("static-command", IterableExtensions.<String>head(reg.getCommands()));
ExecuteCommandParams _executeCommandParams = new ExecuteCommandParams();
final Procedure1<ExecuteCommandParams> _function_1 = (ExecuteCommandParams it) -> {
it.setCommand("static-command");
};
ExecuteCommandParams _doubleArrow = ObjectExtensions.<ExecuteCommandParams>operator_doubleArrow(_executeCommandParams, _function_1);
reg.executeCommand(_doubleArrow, null, null);
ExecuteCommandParams _executeCommandParams_1 = new ExecuteCommandParams();
final Procedure1<ExecuteCommandParams> _function_2 = (ExecuteCommandParams it) -> {
it.setCommand("dynamic-command");
};
ExecuteCommandParams _doubleArrow_1 = ObjectExtensions.<ExecuteCommandParams>operator_doubleArrow(_executeCommandParams_1, _function_2);
reg.executeCommand(_doubleArrow_1, null, null);
Assert.assertEquals(Collections.<String>unmodifiableSet(CollectionLiterals.<String>newHashSet("static-command")), this.commandsExecuted);
this.commandsExecuted.clear();
final IDisposable disposable = this.register.apply("dynamic-command");
ExecuteCommandParams _executeCommandParams_2 = new ExecuteCommandParams();
final Procedure1<ExecuteCommandParams> _function_3 = (ExecuteCommandParams it) -> {
it.setCommand("dynamic-command");
};
ExecuteCommandParams _doubleArrow_2 = ObjectExtensions.<ExecuteCommandParams>operator_doubleArrow(_executeCommandParams_2, _function_3);
reg.executeCommand(_doubleArrow_2, null, null);
Assert.assertEquals(Collections.<String>unmodifiableSet(CollectionLiterals.<String>newHashSet("dynamic-command")), this.commandsExecuted);
this.commandsExecuted.clear();
disposable.dispose();
ExecuteCommandParams _executeCommandParams_3 = new ExecuteCommandParams();
final Procedure1<ExecuteCommandParams> _function_4 = (ExecuteCommandParams it) -> {
it.setCommand("dynamic-command");
};
ExecuteCommandParams _doubleArrow_3 = ObjectExtensions.<ExecuteCommandParams>operator_doubleArrow(_executeCommandParams_3, _function_4);
reg.executeCommand(_doubleArrow_3, null, null);
Assert.assertEquals(Collections.<Object>unmodifiableSet(CollectionLiterals.<Object>newHashSet()), this.commandsExecuted);
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 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.Procedures.Procedure1 in project xtext-core by eclipse.
the class AbstractLanguageServerTest method didCreateWatchedFiles.
protected void didCreateWatchedFiles(final String... fileUris) {
DidChangeWatchedFilesParams _didChangeWatchedFilesParams = new DidChangeWatchedFilesParams();
final Procedure1<DidChangeWatchedFilesParams> _function = (DidChangeWatchedFilesParams it) -> {
for (final String fileUri : fileUris) {
List<FileEvent> _changes = it.getChanges();
FileEvent _fileEvent = new FileEvent();
final Procedure1<FileEvent> _function_1 = (FileEvent it_1) -> {
it_1.setUri(fileUri);
it_1.setType(FileChangeType.Created);
};
FileEvent _doubleArrow = ObjectExtensions.<FileEvent>operator_doubleArrow(_fileEvent, _function_1);
_changes.add(_doubleArrow);
}
};
DidChangeWatchedFilesParams _doubleArrow = ObjectExtensions.<DidChangeWatchedFilesParams>operator_doubleArrow(_didChangeWatchedFilesParams, _function);
this.languageServer.didChangeWatchedFiles(_doubleArrow);
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-core by eclipse.
the class AbstractLanguageServerTest method open.
protected void open(final String fileUri, final String langaugeId, final String model) {
DidOpenTextDocumentParams _didOpenTextDocumentParams = new DidOpenTextDocumentParams();
final Procedure1<DidOpenTextDocumentParams> _function = (DidOpenTextDocumentParams it) -> {
TextDocumentItem _textDocumentItem = new TextDocumentItem();
final Procedure1<TextDocumentItem> _function_1 = (TextDocumentItem it_1) -> {
it_1.setUri(fileUri);
it_1.setLanguageId(langaugeId);
it_1.setVersion(1);
it_1.setText(model);
};
TextDocumentItem _doubleArrow = ObjectExtensions.<TextDocumentItem>operator_doubleArrow(_textDocumentItem, _function_1);
it.setTextDocument(_doubleArrow);
};
DidOpenTextDocumentParams _doubleArrow = ObjectExtensions.<DidOpenTextDocumentParams>operator_doubleArrow(_didOpenTextDocumentParams, _function);
this.languageServer.didOpen(_doubleArrow);
}
Aggregations