Search in sources :

Example 1 with CodeActionParams

use of org.eclipse.lsp4j.CodeActionParams 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);
    }
}
Also used : CodeActionParams(org.eclipse.lsp4j.CodeActionParams) TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) Extension(org.eclipse.xtext.xbase.lib.Extension) CodeActionContext(org.eclipse.lsp4j.CodeActionContext) Command(org.eclipse.lsp4j.Command) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) List(java.util.List) CompletionList(org.eclipse.lsp4j.CompletionList)

Aggregations

List (java.util.List)1 CodeActionContext (org.eclipse.lsp4j.CodeActionContext)1 CodeActionParams (org.eclipse.lsp4j.CodeActionParams)1 Command (org.eclipse.lsp4j.Command)1 CompletionList (org.eclipse.lsp4j.CompletionList)1 TextDocumentIdentifier (org.eclipse.lsp4j.TextDocumentIdentifier)1 Extension (org.eclipse.xtext.xbase.lib.Extension)1 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)1