Search in sources :

Example 1 with Extension

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);
    }
}
Also used : Extension(org.eclipse.xtext.xbase.lib.Extension) ExecuteCommandParams(org.eclipse.lsp4j.ExecuteCommandParams)

Example 2 with Extension

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);
    }
}
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)

Example 3 with Extension

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);
    }
}
Also used : Extension(org.eclipse.xtext.xbase.lib.Extension) TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) Position(org.eclipse.lsp4j.Position) SignatureHelpConfiguration(org.eclipse.xtext.testing.SignatureHelpConfiguration) SignatureHelp(org.eclipse.lsp4j.SignatureHelp) TextDocumentPositionParams(org.eclipse.lsp4j.TextDocumentPositionParams)

Example 4 with Extension

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);
    }
}
Also used : TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) Position(org.eclipse.lsp4j.Position) Extension(org.eclipse.xtext.xbase.lib.Extension) ReferenceTestConfiguration(org.eclipse.xtext.testing.ReferenceTestConfiguration) ReferenceParams(org.eclipse.lsp4j.ReferenceParams) ReferenceContext(org.eclipse.lsp4j.ReferenceContext) List(java.util.List) CompletionList(org.eclipse.lsp4j.CompletionList) Location(org.eclipse.lsp4j.Location)

Example 5 with Extension

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);
    }
}
Also used : TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) Extension(org.eclipse.xtext.xbase.lib.Extension) CodeLens(org.eclipse.lsp4j.CodeLens) CodeLensParams(org.eclipse.lsp4j.CodeLensParams) List(java.util.List) CompletionList(org.eclipse.lsp4j.CompletionList)

Aggregations

Extension (org.eclipse.xtext.xbase.lib.Extension)34 List (java.util.List)11 TextDocumentIdentifier (org.eclipse.lsp4j.TextDocumentIdentifier)11 CompletionList (org.eclipse.lsp4j.CompletionList)9 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)8 Test (org.junit.Test)8 Position (org.eclipse.lsp4j.Position)6 ContentAssistGrammarNaming (org.eclipse.xtext.xtext.generator.parser.antlr.ContentAssistGrammarNaming)6 TextDocumentPositionParams (org.eclipse.lsp4j.TextDocumentPositionParams)4 MutableFieldDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableFieldDeclaration)4 StringConcatenationClient (org.eclipse.xtend2.lib.StringConcatenationClient)4 IFormattableDocument (org.eclipse.xtext.formatting2.IFormattableDocument)4 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)4 TypeReference (org.eclipse.xtext.xtext.generator.model.TypeReference)4 Set (java.util.Set)3 Resource (org.eclipse.emf.ecore.resource.Resource)3 Data (org.eclipse.xtend.lib.annotations.Data)3 AnnotationReference (org.eclipse.xtend.lib.macro.declaration.AnnotationReference)3 IHiddenRegionFormatter (org.eclipse.xtext.formatting2.IHiddenRegionFormatter)3 GenericFormatter (org.eclipse.xtext.formatting2.internal.GenericFormatter)3