use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-core by eclipse.
the class CommandServiceTest method testExecute.
@Test
public void testExecute() {
final Procedure1<InitializeParams> _function = (InitializeParams it) -> {
ClientCapabilities _clientCapabilities = new ClientCapabilities();
final Procedure1<ClientCapabilities> _function_1 = (ClientCapabilities it_1) -> {
WorkspaceClientCapabilities _workspaceClientCapabilities = new WorkspaceClientCapabilities();
final Procedure1<WorkspaceClientCapabilities> _function_2 = (WorkspaceClientCapabilities it_2) -> {
ExecuteCommandCapabilities _executeCommandCapabilities = new ExecuteCommandCapabilities();
final Procedure1<ExecuteCommandCapabilities> _function_3 = (ExecuteCommandCapabilities it_3) -> {
it_3.setDynamicRegistration(Boolean.valueOf(true));
};
ExecuteCommandCapabilities _doubleArrow = ObjectExtensions.<ExecuteCommandCapabilities>operator_doubleArrow(_executeCommandCapabilities, _function_3);
it_2.setExecuteCommand(_doubleArrow);
};
WorkspaceClientCapabilities _doubleArrow = ObjectExtensions.<WorkspaceClientCapabilities>operator_doubleArrow(_workspaceClientCapabilities, _function_2);
it_1.setWorkspace(_doubleArrow);
};
ClientCapabilities _doubleArrow = ObjectExtensions.<ClientCapabilities>operator_doubleArrow(_clientCapabilities, _function_1);
it.setCapabilities(_doubleArrow);
};
this.initialize(_function);
final Procedure1<CommandServiceTest.TestExecuteCommandConfiguration> _function_1 = (CommandServiceTest.TestExecuteCommandConfiguration it) -> {
it.command = "testlang.a";
final Consumer<Object> _function_2 = (Object it_1) -> {
if ((it_1 instanceof String)) {
this.assertEquals("a", ((String) it_1));
} else {
Assert.fail("no string");
}
};
it.assertCommandResult = _function_2;
};
this.testExecuteCommand(_function_1);
final Procedure1<CommandServiceTest.TestExecuteCommandConfiguration> _function_2 = (CommandServiceTest.TestExecuteCommandConfiguration it) -> {
it.command = "testlang.b";
final Consumer<Object> _function_3 = (Object it_1) -> {
if ((it_1 instanceof String)) {
this.assertEquals("b", ((String) it_1));
} else {
Assert.fail("no string");
}
};
it.assertCommandResult = _function_3;
};
this.testExecuteCommand(_function_2);
final Procedure1<CommandServiceTest.TestExecuteCommandConfiguration> _function_3 = (CommandServiceTest.TestExecuteCommandConfiguration it) -> {
it.command = "doesnotexist.c";
final Consumer<Object> _function_4 = (Object it_1) -> {
Assert.assertNull(it_1);
};
it.assertCommandResult = _function_4;
};
this.testExecuteCommand(_function_3);
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-core by eclipse.
the class ServerTest method testMissingInitialize.
@Test
public void testMissingInitialize() {
try {
try {
TextDocumentPositionParams _textDocumentPositionParams = new TextDocumentPositionParams();
final Procedure1<TextDocumentPositionParams> _function = (TextDocumentPositionParams it) -> {
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier();
final Procedure1<TextDocumentIdentifier> _function_1 = (TextDocumentIdentifier it_1) -> {
it_1.setUri("file:/home/test/workspace/mydoc.testlang");
};
TextDocumentIdentifier _doubleArrow = ObjectExtensions.<TextDocumentIdentifier>operator_doubleArrow(_textDocumentIdentifier, _function_1);
it.setTextDocument(_doubleArrow);
};
TextDocumentPositionParams _doubleArrow = ObjectExtensions.<TextDocumentPositionParams>operator_doubleArrow(_textDocumentPositionParams, _function);
this.languageServer.definition(_doubleArrow).get();
Assert.fail("Expected a ResponseErrorException");
} catch (final Throwable _t) {
if (_t instanceof ExecutionException) {
final ExecutionException exception = (ExecutionException) _t;
Throwable _cause = exception.getCause();
Assert.assertEquals(ResponseErrorCode.serverNotInitialized.getValue(), ((ResponseErrorException) _cause).getResponseError().getCode());
} else {
throw Exceptions.sneakyThrow(_t);
}
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-core by eclipse.
the class UnknownProjectConfigTest method testCompletionWithInmemoryScheme_01.
@Test
public void testCompletionWithInmemoryScheme_01() {
final Procedure1<InitializeParams> _function = (InitializeParams it) -> {
it.setRootUri(null);
};
this.initialize(_function);
final String inmemoryUri = "inmemory:/mydoc.testlang";
DidOpenTextDocumentParams _didOpenTextDocumentParams = new DidOpenTextDocumentParams();
final Procedure1<DidOpenTextDocumentParams> _function_1 = (DidOpenTextDocumentParams it) -> {
TextDocumentItem _textDocumentItem = new TextDocumentItem();
final Procedure1<TextDocumentItem> _function_2 = (TextDocumentItem it_1) -> {
it_1.setUri(inmemoryUri);
StringConcatenation _builder = new StringConcatenation();
_builder.append("type Foo {}");
_builder.newLine();
it_1.setText(_builder.toString());
};
TextDocumentItem _doubleArrow = ObjectExtensions.<TextDocumentItem>operator_doubleArrow(_textDocumentItem, _function_2);
it.setTextDocument(_doubleArrow);
};
DidOpenTextDocumentParams _doubleArrow = ObjectExtensions.<DidOpenTextDocumentParams>operator_doubleArrow(_didOpenTextDocumentParams, _function_1);
this.languageServer.didOpen(_doubleArrow);
this.checkCompletion(inmemoryUri);
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-core by eclipse.
the class CodeActionService method recordWorkspaceEdit.
private WorkspaceEdit recordWorkspaceEdit(final Document doc, final XtextResource resource, final IChangeSerializer.IModification<Resource> mod) {
try {
final XtextResourceSet rs = new XtextResourceSet();
final Resource copy = rs.createResource(resource.getURI());
String _text = resource.getParseResult().getRootNode().getText();
StringInputStream _stringInputStream = new StringInputStream(_text);
copy.load(_stringInputStream, CollectionLiterals.<Object, Object>emptyMap());
this.serializer.<Resource>addModification(copy, mod);
final ArrayList<IEmfResourceChange> documentchanges = CollectionLiterals.<IEmfResourceChange>newArrayList();
this.serializer.applyModifications(CollectionBasedAcceptor.<IEmfResourceChange>of(documentchanges));
WorkspaceEdit _workspaceEdit = new WorkspaceEdit();
final Procedure1<WorkspaceEdit> _function = (WorkspaceEdit it) -> {
Iterable<ITextDocumentChange> _filter = Iterables.<ITextDocumentChange>filter(documentchanges, ITextDocumentChange.class);
for (final ITextDocumentChange documentchange : _filter) {
{
final Function1<ITextReplacement, TextEdit> _function_1 = (ITextReplacement replacement) -> {
TextEdit _textEdit = new TextEdit();
final Procedure1<TextEdit> _function_2 = (TextEdit it_1) -> {
it_1.setNewText(replacement.getReplacementText());
Position _position = doc.getPosition(replacement.getOffset());
Position _position_1 = doc.getPosition(replacement.getEndOffset());
Range _range = new Range(_position, _position_1);
it_1.setRange(_range);
};
return ObjectExtensions.<TextEdit>operator_doubleArrow(_textEdit, _function_2);
};
final List<TextEdit> edits = ListExtensions.<ITextReplacement, TextEdit>map(documentchange.getReplacements(), _function_1);
it.getChanges().put(documentchange.getNewURI().toString(), edits);
}
}
};
return ObjectExtensions.<WorkspaceEdit>operator_doubleArrow(_workspaceEdit, _function);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-core by eclipse.
the class CodeActionService method fixInvalidName.
private Command fixInvalidName(final Diagnostic d, final Document doc, final XtextResource res, final CodeActionParams params) {
final String string = doc.getSubstring(d.getRange());
Command _command = new Command();
final Procedure1<Command> _function = (Command it) -> {
it.setCommand("my.textedit.command");
StringConcatenation _builder = new StringConcatenation();
_builder.append("Make \'");
_builder.append(string);
_builder.append("\' upper case");
it.setTitle(_builder.toString());
WorkspaceEdit _workspaceEdit = new WorkspaceEdit();
final Procedure1<WorkspaceEdit> _function_1 = (WorkspaceEdit it_1) -> {
TextEdit _textEdit = new TextEdit();
final Procedure1<TextEdit> _function_2 = (TextEdit it_2) -> {
it_2.setNewText(StringExtensions.toFirstUpper(string));
it_2.setRange(d.getRange());
};
TextEdit _doubleArrow = ObjectExtensions.<TextEdit>operator_doubleArrow(_textEdit, _function_2);
it_1.getChanges().put(params.getTextDocument().getUri(), Collections.<TextEdit>unmodifiableList(CollectionLiterals.<TextEdit>newArrayList(_doubleArrow)));
};
WorkspaceEdit _doubleArrow = ObjectExtensions.<WorkspaceEdit>operator_doubleArrow(_workspaceEdit, _function_1);
it.setArguments(Collections.<Object>unmodifiableList(CollectionLiterals.<Object>newArrayList(_doubleArrow)));
};
return ObjectExtensions.<Command>operator_doubleArrow(_command, _function);
}
Aggregations