Search in sources :

Example 56 with Procedure1

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));
}
Also used : CodeLens(org.eclipse.lsp4j.CodeLens) Command(org.eclipse.lsp4j.Command) Position(org.eclipse.lsp4j.Position) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1)

Example 57 with Procedure1

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);
}
Also used : WorkspaceClientCapabilities(org.eclipse.lsp4j.WorkspaceClientCapabilities) ClientCapabilities(org.eclipse.lsp4j.ClientCapabilities) ExecuteCommandParams(org.eclipse.lsp4j.ExecuteCommandParams) ExecutableCommandRegistry(org.eclipse.xtext.ide.server.commands.ExecutableCommandRegistry) WorkspaceClientCapabilities(org.eclipse.lsp4j.WorkspaceClientCapabilities) IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) ExecuteCommandCapabilities(org.eclipse.lsp4j.ExecuteCommandCapabilities) IDisposable(org.eclipse.xtext.util.IDisposable) Test(org.junit.Test)

Example 58 with Procedure1

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);
    }
}
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 59 with Procedure1

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);
}
Also used : FileEvent(org.eclipse.lsp4j.FileEvent) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) List(java.util.List) CompletionList(org.eclipse.lsp4j.CompletionList) DidChangeWatchedFilesParams(org.eclipse.lsp4j.DidChangeWatchedFilesParams)

Example 60 with Procedure1

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);
}
Also used : TextDocumentItem(org.eclipse.lsp4j.TextDocumentItem) DidOpenTextDocumentParams(org.eclipse.lsp4j.DidOpenTextDocumentParams) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1)

Aggregations

Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)173 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)99 Test (org.junit.Test)98 IHiddenRegionFormatter (org.eclipse.xtext.formatting2.IHiddenRegionFormatter)28 IFormattableDocument (org.eclipse.xtext.formatting2.IFormattableDocument)20 GenericFormatter (org.eclipse.xtext.formatting2.internal.GenericFormatter)20 ITextRegionExtensions (org.eclipse.xtext.formatting2.regionaccess.ITextRegionExtensions)20 GenericFormatterTestRequest (org.eclipse.xtext.formatting2.internal.GenericFormatterTestRequest)18 AbstractXtendCompilerTest (org.eclipse.xtend.core.tests.compiler.AbstractXtendCompilerTest)16 CompilationTestHelper (org.eclipse.xtext.xbase.testing.CompilationTestHelper)16 EList (org.eclipse.emf.common.util.EList)14 IChangeSerializer (org.eclipse.xtext.ide.serializer.IChangeSerializer)14 MapBasedPreferenceValues (org.eclipse.xtext.preferences.MapBasedPreferenceValues)14 IDList (org.eclipse.xtext.formatting2.internal.formattertestlanguage.IDList)13 EObject (org.eclipse.emf.ecore.EObject)11 Method (java.lang.reflect.Method)10 AbstractBuilderTest (org.eclipse.xtend.ide.tests.codebuilder.AbstractBuilderTest)10 ITextRegionAccess (org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess)10 MandatoryValue (org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.MandatoryValue)10 Field (java.lang.reflect.Field)9