Search in sources :

Example 6 with ExecuteCommandCapabilities

use of org.eclipse.lsp4j.ExecuteCommandCapabilities in project xtext-core by eclipse.

the class ExecutableCommandRegistry method initialize.

public void initialize(Iterable<? extends IResourceServiceProvider> allLanguages, ClientCapabilities capabilities, LanguageClient client) {
    this.client = client;
    this.registeredCommands = HashMultimap.create();
    boolean hasDynamicRegistration = false;
    WorkspaceClientCapabilities workspace = capabilities.getWorkspace();
    if (workspace != null) {
        ExecuteCommandCapabilities executeCommandCapabilities = workspace.getExecuteCommand();
        if (executeCommandCapabilities != null) {
            Boolean dynamicRegistration = executeCommandCapabilities.getDynamicRegistration();
            if (dynamicRegistration != null) {
                hasDynamicRegistration = dynamicRegistration.booleanValue();
            }
        }
    }
    for (IResourceServiceProvider lang : allLanguages) {
        IExecutableCommandService service = lang.get(IExecutableCommandService.class);
        if (service != null) {
            List<String> commands = service.initialize();
            for (String c : commands) {
                registeredCommands.put(c, service);
            }
            if (hasDynamicRegistration) {
                service.initializeDynamicRegistration((String command) -> {
                    return register(command, service);
                });
            }
        }
    }
}
Also used : WorkspaceClientCapabilities(org.eclipse.lsp4j.WorkspaceClientCapabilities) IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider) ExecuteCommandCapabilities(org.eclipse.lsp4j.ExecuteCommandCapabilities)

Aggregations

ExecuteCommandCapabilities (org.eclipse.lsp4j.ExecuteCommandCapabilities)6 WorkspaceClientCapabilities (org.eclipse.lsp4j.WorkspaceClientCapabilities)6 ClientCapabilities (org.eclipse.lsp4j.ClientCapabilities)5 InitializeParams (org.eclipse.lsp4j.InitializeParams)4 TextDocumentClientCapabilities (org.eclipse.lsp4j.TextDocumentClientCapabilities)3 CompletableFuture (java.util.concurrent.CompletableFuture)2 InitializeResult (org.eclipse.lsp4j.InitializeResult)2 IResourceServiceProvider (org.eclipse.xtext.resource.IResourceServiceProvider)2 Test (org.junit.Test)2 Objects (com.google.common.base.Objects)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableMultimap (com.google.common.collect.ImmutableMultimap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 LinkedListMultimap (com.google.common.collect.LinkedListMultimap)1 Lists (com.google.common.collect.Lists)1 Multimap (com.google.common.collect.Multimap)1 Inject (com.google.inject.Inject)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1