use of org.eclipse.lsp4j.CodeLens 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.lsp4j.CodeLens 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);
}
}
use of org.eclipse.lsp4j.CodeLens in project xtext-core by eclipse.
the class LanguageServerImpl method resolveCodeLens.
@Override
public CompletableFuture<CodeLens> resolveCodeLens(final CodeLens unresolved) {
final URI uri = this.uninstallURI(unresolved);
if ((uri == null)) {
return CompletableFuture.<CodeLens>completedFuture(unresolved);
}
final Function1<CancelIndicator, CodeLens> _function = (CancelIndicator cancelIndicator) -> {
final IResourceServiceProvider resourceServiceProvider = this.languagesRegistry.getResourceServiceProvider(uri);
ICodeLensResolver _get = null;
if (resourceServiceProvider != null) {
_get = resourceServiceProvider.<ICodeLensResolver>get(ICodeLensResolver.class);
}
final ICodeLensResolver resolver = _get;
if ((resolver == null)) {
return unresolved;
}
final Function2<Document, XtextResource, CodeLens> _function_1 = (Document document, XtextResource resource) -> {
final CodeLens result = resolver.resolveCodeLens(document, resource, unresolved, cancelIndicator);
return result;
};
return this.workspaceManager.<CodeLens>doRead(uri, _function_1);
};
return this.requestManager.<CodeLens>runRead(_function);
}
use of org.eclipse.lsp4j.CodeLens in project xtext-core by eclipse.
the class LanguageServerImpl method installURI.
private void installURI(final List<? extends CodeLens> codeLenses, final String uri) {
for (final CodeLens lens : codeLenses) {
Object _data = lens.getData();
boolean _tripleNotEquals = (_data != null);
if (_tripleNotEquals) {
lens.setData(CollectionLiterals.<Object>newArrayList(uri, lens.getData()));
} else {
lens.setData(uri);
}
}
}
use of org.eclipse.lsp4j.CodeLens in project xtext-core by eclipse.
the class CodeLensTest method testCodeLens.
@Test
public void testCodeLens() {
final Procedure1<AbstractLanguageServerTest.TestCodeLensConfiguration> _function = (AbstractLanguageServerTest.TestCodeLensConfiguration 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());
final Procedure1<List<? extends CodeLens>> _function_1 = (List<? extends CodeLens> it_1) -> {
this.assertEquals("Do Awesome Stuff(RESOLVED)", IterableExtensions.head(it_1).getCommand().getTitle());
Object _data = IterableExtensions.head(it_1).getData();
Assert.assertEquals(1, ((Position) _data).getLine());
};
it.setAssertCodeLenses(_function_1);
};
this.testCodeLens(_function);
}
Aggregations