Search in sources :

Example 1 with CompletionOptions

use of org.eclipse.lsp4j.CompletionOptions in project sts4 by spring-projects.

the class SimpleLanguageServer method getServerCapabilities.

protected final ServerCapabilities getServerCapabilities() {
    ServerCapabilities c = new ServerCapabilities();
    c.setTextDocumentSync(TextDocumentSyncKind.Incremental);
    c.setHoverProvider(true);
    CompletionOptions completionProvider = new CompletionOptions();
    completionProvider.setResolveProvider(hasLazyCompletionResolver());
    c.setCompletionProvider(completionProvider);
    if (hasQuickFixes()) {
        c.setCodeActionProvider(true);
    }
    if (hasDefinitionHandler()) {
        c.setDefinitionProvider(true);
    }
    if (hasReferencesHandler()) {
        c.setReferencesProvider(true);
    }
    if (hasDocumentSymbolHandler()) {
        c.setDocumentSymbolProvider(true);
    }
    if (hasDocumentHighlightHandler()) {
        c.setDocumentHighlightProvider(true);
    }
    if (hasCodeLensHandler()) {
        CodeLensOptions codeLensOptions = new CodeLensOptions();
        codeLensOptions.setResolveProvider(hasCodeLensResolveProvider());
        c.setCodeLensProvider(codeLensOptions);
    }
    if (hasExecuteCommandSupport && hasQuickFixes()) {
        c.setExecuteCommandProvider(new ExecuteCommandOptions(ImmutableList.of(CODE_ACTION_COMMAND_ID)));
    }
    if (hasWorkspaceSymbolHandler()) {
        c.setWorkspaceSymbolProvider(true);
    }
    WorkspaceFoldersOptions workspaceFoldersOptions = new WorkspaceFoldersOptions();
    workspaceFoldersOptions.setSupported(true);
    workspaceFoldersOptions.setChangeNotifications(WORKSPACE_FOLDERS_CAPABILITY_ID);
    WorkspaceServerCapabilities workspaceServerCapabilities = new WorkspaceServerCapabilities();
    workspaceServerCapabilities.setWorkspaceFolders(workspaceFoldersOptions);
    c.setWorkspace(workspaceServerCapabilities);
    return c;
}
Also used : CompletionOptions(org.eclipse.lsp4j.CompletionOptions) ServerCapabilities(org.eclipse.lsp4j.ServerCapabilities) WorkspaceServerCapabilities(org.eclipse.lsp4j.WorkspaceServerCapabilities) CodeLensOptions(org.eclipse.lsp4j.CodeLensOptions) ExecuteCommandOptions(org.eclipse.lsp4j.ExecuteCommandOptions) WorkspaceFoldersOptions(org.eclipse.lsp4j.WorkspaceFoldersOptions) WorkspaceServerCapabilities(org.eclipse.lsp4j.WorkspaceServerCapabilities)

Example 2 with CompletionOptions

use of org.eclipse.lsp4j.CompletionOptions in project vscode-nextgenas by BowlerHatLLC.

the class ActionScriptLanguageServer method initialize.

/**
     * Tells Visual Studio Code about the language server's capabilities.
     */
@Override
public CompletableFuture<InitializeResult> initialize(InitializeParams params) {
    Path workspaceRoot = Paths.get(params.getRootPath()).toAbsolutePath().normalize();
    projectConfigStrategy.setASConfigPath(workspaceRoot.resolve(ASCONFIG_JSON));
    textDocumentService.setWorkspaceRoot(workspaceRoot);
    InitializeResult result = new InitializeResult();
    ServerCapabilities serverCapabilities = new ServerCapabilities();
    serverCapabilities.setTextDocumentSync(TextDocumentSyncKind.Incremental);
    serverCapabilities.setCodeActionProvider(true);
    CompletionOptions completionOptions = new CompletionOptions();
    completionOptions.setTriggerCharacters(Arrays.asList(".", ":", " ", "<"));
    serverCapabilities.setCompletionProvider(completionOptions);
    serverCapabilities.setDefinitionProvider(true);
    serverCapabilities.setDocumentSymbolProvider(true);
    serverCapabilities.setDocumentHighlightProvider(false);
    serverCapabilities.setDocumentRangeFormattingProvider(false);
    serverCapabilities.setHoverProvider(true);
    serverCapabilities.setReferencesProvider(true);
    serverCapabilities.setRenameProvider(true);
    SignatureHelpOptions signatureHelpOptions = new SignatureHelpOptions();
    signatureHelpOptions.setTriggerCharacters(Arrays.asList("(", ","));
    serverCapabilities.setSignatureHelpProvider(signatureHelpOptions);
    serverCapabilities.setWorkspaceSymbolProvider(true);
    result.setCapabilities(serverCapabilities);
    return CompletableFuture.completedFuture(result);
}
Also used : Path(java.nio.file.Path) CompletionOptions(org.eclipse.lsp4j.CompletionOptions) SignatureHelpOptions(org.eclipse.lsp4j.SignatureHelpOptions) InitializeResult(org.eclipse.lsp4j.InitializeResult) ServerCapabilities(org.eclipse.lsp4j.ServerCapabilities)

Example 3 with CompletionOptions

use of org.eclipse.lsp4j.CompletionOptions in project eclipse.jdt.ls by eclipse.

the class InitHandler method initialize.

@SuppressWarnings("unchecked")
InitializeResult initialize(InitializeParams param) {
    logInfo("Initializing Java Language Server " + JavaLanguageServerPlugin.getVersion());
    Map<?, ?> initializationOptions = this.getInitializationOptions(param);
    Map<String, Object> extendedClientCapabilities = getInitializationOption(initializationOptions, "extendedClientCapabilities", Map.class);
    if (param.getCapabilities() == null) {
        preferenceManager.updateClientPrefences(new ClientCapabilities(), extendedClientCapabilities);
    } else {
        preferenceManager.updateClientPrefences(param.getCapabilities(), extendedClientCapabilities);
    }
    Collection<IPath> rootPaths = new ArrayList<>();
    Collection<String> workspaceFolders = getInitializationOption(initializationOptions, "workspaceFolders", Collection.class);
    if (workspaceFolders != null && !workspaceFolders.isEmpty()) {
        for (String uri : workspaceFolders) {
            IPath filePath = ResourceUtils.filePathFromURI(uri);
            if (filePath != null) {
                rootPaths.add(filePath);
            }
        }
    } else {
        String rootPath = param.getRootUri();
        if (rootPath == null) {
            rootPath = param.getRootPath();
            if (rootPath != null) {
                logInfo("In LSP 3.0, InitializeParams.rootPath is deprecated in favour of InitializeParams.rootUri!");
            }
        }
        if (rootPath != null) {
            IPath filePath = ResourceUtils.filePathFromURI(rootPath);
            if (filePath != null) {
                rootPaths.add(filePath);
            }
        }
    }
    if (rootPaths.isEmpty()) {
        IPath workspaceLocation = ResourcesPlugin.getWorkspace().getRoot().getLocation();
        logInfo("No workspace folders or root uri was defined. Falling back on " + workspaceLocation);
        rootPaths.add(workspaceLocation);
    }
    if (initializationOptions.get(SETTINGS_KEY) instanceof Map) {
        Object settings = initializationOptions.get(SETTINGS_KEY);
        @SuppressWarnings("unchecked") Preferences prefs = Preferences.createFrom((Map<String, Object>) settings);
        preferenceManager.update(prefs);
    }
    triggerInitialization(rootPaths);
    addWorkspaceDiagnosticsHandler();
    Integer processId = param.getProcessId();
    if (processId != null) {
        JavaLanguageServerPlugin.getLanguageServer().setParentProcessId(processId.longValue());
    }
    try {
        Collection<String> bundleList = getInitializationOption(initializationOptions, BUNDLES_KEY, Collection.class);
        BundleUtils.loadBundles(bundleList);
    } catch (CoreException e) {
        // The additional plug-ins should not affect the main language server loading.
        JavaLanguageServerPlugin.logException("Failed to load extension bundles ", e);
    }
    InitializeResult result = new InitializeResult();
    ServerCapabilities capabilities = new ServerCapabilities();
    capabilities.setCompletionProvider(new CompletionOptions(Boolean.TRUE, Arrays.asList(".", "@", "#")));
    if (!preferenceManager.getClientPreferences().isFormattingDynamicRegistrationSupported()) {
        capabilities.setDocumentFormattingProvider(Boolean.TRUE);
    }
    if (!preferenceManager.getClientPreferences().isRangeFormattingDynamicRegistrationSupported()) {
        capabilities.setDocumentRangeFormattingProvider(Boolean.TRUE);
    }
    if (!preferenceManager.getClientPreferences().isCodeLensDynamicRegistrationSupported()) {
        capabilities.setCodeLensProvider(new CodeLensOptions(true));
    }
    if (!preferenceManager.getClientPreferences().isSignatureHelpDynamicRegistrationSupported()) {
        capabilities.setSignatureHelpProvider(SignatureHelpHandler.createOptions());
    }
    if (!preferenceManager.getClientPreferences().isRenameDynamicRegistrationSupported()) {
        capabilities.setRenameProvider(Boolean.TRUE);
    }
    if (!preferenceManager.getClientPreferences().isCodeActionDynamicRegistered()) {
        capabilities.setCodeActionProvider(Boolean.TRUE);
    }
    if (!preferenceManager.getClientPreferences().isExecuteCommandDynamicRegistrationSupported()) {
        Set<String> commands = WorkspaceExecuteCommandHandler.getCommands();
        capabilities.setExecuteCommandProvider(new ExecuteCommandOptions(new ArrayList<>(commands)));
    }
    if (!preferenceManager.getClientPreferences().isWorkspaceSymbolDynamicRegistered()) {
        capabilities.setWorkspaceSymbolProvider(Boolean.TRUE);
    }
    if (!preferenceManager.getClientPreferences().isDocumentSymbolDynamicRegistered()) {
        capabilities.setDocumentSymbolProvider(Boolean.TRUE);
    }
    if (!preferenceManager.getClientPreferences().isDefinitionDynamicRegistered()) {
        capabilities.setDefinitionProvider(Boolean.TRUE);
    }
    if (!preferenceManager.getClientPreferences().isHoverDynamicRegistered()) {
        capabilities.setHoverProvider(Boolean.TRUE);
    }
    if (!preferenceManager.getClientPreferences().isReferencesDynamicRegistered()) {
        capabilities.setReferencesProvider(Boolean.TRUE);
    }
    if (!preferenceManager.getClientPreferences().isDocumentHighlightDynamicRegistered()) {
        capabilities.setDocumentHighlightProvider(Boolean.TRUE);
    }
    TextDocumentSyncOptions textDocumentSyncOptions = new TextDocumentSyncOptions();
    textDocumentSyncOptions.setOpenClose(Boolean.TRUE);
    textDocumentSyncOptions.setSave(new SaveOptions(Boolean.TRUE));
    textDocumentSyncOptions.setChange(TextDocumentSyncKind.Incremental);
    if (preferenceManager.getClientPreferences().isWillSaveRegistered()) {
        textDocumentSyncOptions.setWillSave(Boolean.TRUE);
    }
    if (preferenceManager.getClientPreferences().isWillSaveWaitUntilRegistered()) {
        textDocumentSyncOptions.setWillSaveWaitUntil(Boolean.TRUE);
    }
    capabilities.setTextDocumentSync(textDocumentSyncOptions);
    WorkspaceServerCapabilities wsCapabilities = new WorkspaceServerCapabilities();
    WorkspaceFoldersOptions wsFoldersOptions = new WorkspaceFoldersOptions();
    wsFoldersOptions.setSupported(Boolean.TRUE);
    wsFoldersOptions.setChangeNotifications(Boolean.TRUE);
    wsCapabilities.setWorkspaceFolders(wsFoldersOptions);
    capabilities.setWorkspace(wsCapabilities);
    result.setCapabilities(capabilities);
    return result;
}
Also used : IPath(org.eclipse.core.runtime.IPath) TextDocumentSyncOptions(org.eclipse.lsp4j.TextDocumentSyncOptions) ArrayList(java.util.ArrayList) ClientCapabilities(org.eclipse.lsp4j.ClientCapabilities) WorkspaceFoldersOptions(org.eclipse.lsp4j.WorkspaceFoldersOptions) WorkspaceServerCapabilities(org.eclipse.lsp4j.WorkspaceServerCapabilities) CompletionOptions(org.eclipse.lsp4j.CompletionOptions) InitializeResult(org.eclipse.lsp4j.InitializeResult) CoreException(org.eclipse.core.runtime.CoreException) ServerCapabilities(org.eclipse.lsp4j.ServerCapabilities) WorkspaceServerCapabilities(org.eclipse.lsp4j.WorkspaceServerCapabilities) CodeLensOptions(org.eclipse.lsp4j.CodeLensOptions) SaveOptions(org.eclipse.lsp4j.SaveOptions) Preferences(org.eclipse.jdt.ls.core.internal.preferences.Preferences) ExecuteCommandOptions(org.eclipse.lsp4j.ExecuteCommandOptions) Map(java.util.Map)

Example 4 with CompletionOptions

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

the class LanguageServerImpl method createServerCapabilities.

/**
 * Configure the server capabilities for this instance.
 *
 * @param params
 *            the initialization parametrs
 * @return the server capabilities
 * @since 2.20
 */
protected ServerCapabilities createServerCapabilities(InitializeParams params) {
    ServerCapabilities serverCapabilities = new ServerCapabilities();
    serverCapabilities.setHoverProvider(true);
    serverCapabilities.setDefinitionProvider(true);
    serverCapabilities.setReferencesProvider(true);
    serverCapabilities.setDocumentSymbolProvider(true);
    serverCapabilities.setWorkspaceSymbolProvider(true);
    Set<? extends IResourceServiceProvider> allLanguages = getAllLanguages();
    if (allLanguages.stream().anyMatch((serviceProvider) -> serviceProvider.get(ICodeLensService.class) != null)) {
        CodeLensOptions codeLensOptions = new CodeLensOptions();
        codeLensOptions.setResolveProvider(allLanguages.stream().anyMatch((serviceProvider) -> serviceProvider.get(ICodeLensResolver.class) != null));
        serverCapabilities.setCodeLensProvider(codeLensOptions);
    }
    serverCapabilities.setCodeActionProvider(allLanguages.stream().anyMatch((serviceProvider) -> serviceProvider.get(ICodeActionService2.class) != null));
    serverCapabilities.setSignatureHelpProvider(new SignatureHelpOptions(ImmutableList.of("(", ",")));
    serverCapabilities.setTextDocumentSync(TextDocumentSyncKind.Incremental);
    CompletionOptions completionOptions = new CompletionOptions();
    completionOptions.setResolveProvider(false);
    completionOptions.setTriggerCharacters(ImmutableList.of("."));
    serverCapabilities.setCompletionProvider(completionOptions);
    serverCapabilities.setDocumentFormattingProvider(true);
    serverCapabilities.setDocumentRangeFormattingProvider(true);
    serverCapabilities.setDocumentHighlightProvider(true);
    ClientCapabilities clientCapabilities = null;
    if (params != null) {
        clientCapabilities = params.getCapabilities();
    }
    TextDocumentClientCapabilities textDocument = null;
    if (clientCapabilities != null) {
        textDocument = clientCapabilities.getTextDocument();
    }
    RenameCapabilities rename = null;
    FoldingRangeCapabilities folding = null;
    if (textDocument != null) {
        rename = textDocument.getRename();
        folding = textDocument.getFoldingRange();
    }
    if (folding != null) {
        serverCapabilities.setFoldingRangeProvider(allLanguages.stream().anyMatch(serviceProvider -> serviceProvider.get(FoldingRangeService.class) != null));
    }
    Boolean prepareSupport = null;
    if (rename != null) {
        prepareSupport = rename.getPrepareSupport();
    }
    boolean clientPrepareSupport = Objects.equal(Boolean.TRUE, prepareSupport);
    if (clientPrepareSupport && allLanguages.stream().anyMatch(serviceProvider -> serviceProvider.get(IRenameService2.class) != null)) {
        RenameOptions renameOptions = new RenameOptions();
        renameOptions.setPrepareProvider(true);
        serverCapabilities.setRenameProvider(Either.<Boolean, RenameOptions>forRight(renameOptions));
    } else {
        serverCapabilities.setRenameProvider(Either.forLeft(allLanguages.stream().anyMatch((serviceProvider) -> serviceProvider.get(IRenameService2.class) != null)));
    }
    WorkspaceClientCapabilities workspace = null;
    if (clientCapabilities != null) {
        workspace = clientCapabilities.getWorkspace();
    }
    ExecuteCommandCapabilities executeCommand = null;
    if (workspace != null) {
        executeCommand = workspace.getExecuteCommand();
        if (workspace.getWorkspaceFolders() == Boolean.TRUE && workspaceManager.isSupportsWorkspaceFolders()) {
            WorkspaceFoldersOptions workspaceFoldersOptions = new WorkspaceFoldersOptions();
            workspaceFoldersOptions.setSupported(true);
            workspaceFoldersOptions.setChangeNotifications(true);
            serverCapabilities.setWorkspace(new WorkspaceServerCapabilities(workspaceFoldersOptions));
        }
    }
    if (executeCommand != null) {
        commandRegistry.initialize(allLanguages, clientCapabilities, client);
        ExecuteCommandOptions executeCommandOptions = new ExecuteCommandOptions();
        executeCommandOptions.setCommands(commandRegistry.getCommands());
        serverCapabilities.setExecuteCommandProvider(executeCommandOptions);
    }
    for (IResourceServiceProvider language : allLanguages) {
        ICapabilitiesContributor capabilitiesContributor = language.get(ICapabilitiesContributor.class);
        if (capabilitiesContributor != null) {
            capabilitiesContributor.contribute(serverCapabilities, params);
        }
    }
    return serverCapabilities;
}
Also used : Arrays(java.util.Arrays) CodeLensOptions(org.eclipse.lsp4j.CodeLensOptions) DidChangeTextDocumentParams(org.eclipse.lsp4j.DidChangeTextDocumentParams) WorkspaceSymbolParams(org.eclipse.lsp4j.WorkspaceSymbolParams) LanguageServer(org.eclipse.lsp4j.services.LanguageServer) DidSaveTextDocumentParams(org.eclipse.lsp4j.DidSaveTextDocumentParams) PublishDiagnosticsParams(org.eclipse.lsp4j.PublishDiagnosticsParams) Map(java.util.Map) RenameParams(org.eclipse.lsp4j.RenameParams) Endpoint(org.eclipse.lsp4j.jsonrpc.Endpoint) IRenameService2(org.eclipse.xtext.ide.server.rename.IRenameService2) TextDocumentService(org.eclipse.lsp4j.services.TextDocumentService) DiagnosticSeverity(org.eclipse.lsp4j.DiagnosticSeverity) SignatureHelpOptions(org.eclipse.lsp4j.SignatureHelpOptions) ISignatureHelpService(org.eclipse.xtext.ide.server.signatureHelp.ISignatureHelpService) Set(java.util.Set) DocumentOnTypeFormattingParams(org.eclipse.lsp4j.DocumentOnTypeFormattingParams) WorkspaceService(org.eclipse.lsp4j.services.WorkspaceService) LocationLink(org.eclipse.lsp4j.LocationLink) FormattingService(org.eclipse.xtext.ide.server.formatting.FormattingService) ExecuteCommandOptions(org.eclipse.lsp4j.ExecuteCommandOptions) ResourceDescriptionsProvider(org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider) JsonRpcMethod(org.eclipse.lsp4j.jsonrpc.json.JsonRpcMethod) WorkspaceFolder(org.eclipse.lsp4j.WorkspaceFolder) FoldingRange(org.eclipse.lsp4j.FoldingRange) ContentAssistService(org.eclipse.xtext.ide.server.contentassist.ContentAssistService) Pair(org.eclipse.xtext.xbase.lib.Pair) LanguageClientAware(org.eclipse.lsp4j.services.LanguageClientAware) URI(org.eclipse.emf.common.util.URI) IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider) HierarchicalDocumentSymbolService(org.eclipse.xtext.ide.server.symbol.HierarchicalDocumentSymbolService) HoverParams(org.eclipse.lsp4j.HoverParams) Diagnostic(org.eclipse.lsp4j.Diagnostic) Supplier(java.util.function.Supplier) DocumentRangeFormattingParams(org.eclipse.lsp4j.DocumentRangeFormattingParams) Hover(org.eclipse.lsp4j.Hover) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) ArrayList(java.util.ArrayList) IHoverService(org.eclipse.xtext.ide.server.hover.IHoverService) LinkedHashMap(java.util.LinkedHashMap) FileChangeType(org.eclipse.lsp4j.FileChangeType) TextDocumentItem(org.eclipse.lsp4j.TextDocumentItem) TextEdit(org.eclipse.lsp4j.TextEdit) Lists(com.google.common.collect.Lists) DocumentFormattingParams(org.eclipse.lsp4j.DocumentFormattingParams) VersionedTextDocumentIdentifier(org.eclipse.lsp4j.VersionedTextDocumentIdentifier) ImmutableMultimap(com.google.common.collect.ImmutableMultimap) InitializeResult(org.eclipse.lsp4j.InitializeResult) DocumentHighlight(org.eclipse.lsp4j.DocumentHighlight) ServiceEndpoints(org.eclipse.lsp4j.jsonrpc.services.ServiceEndpoints) DidChangeWatchedFilesParams(org.eclipse.lsp4j.DidChangeWatchedFilesParams) DocumentHighlightParams(org.eclipse.lsp4j.DocumentHighlightParams) PrepareRenameResult(org.eclipse.lsp4j.PrepareRenameResult) ICodeActionService2(org.eclipse.xtext.ide.server.codeActions.ICodeActionService2) SignatureHelp(org.eclipse.lsp4j.SignatureHelp) TreeMap(java.util.TreeMap) WorkspaceEdit(org.eclipse.lsp4j.WorkspaceEdit) Issue(org.eclipse.xtext.validation.Issue) RenameOptions(org.eclipse.lsp4j.RenameOptions) DocumentSymbolService(org.eclipse.xtext.ide.server.symbol.DocumentSymbolService) CompletionOptions(org.eclipse.lsp4j.CompletionOptions) IBuildListener(org.eclipse.xtext.ide.server.ILanguageServerAccess.IBuildListener) SignatureHelpParams(org.eclipse.lsp4j.SignatureHelpParams) ClientCapabilities(org.eclipse.lsp4j.ClientCapabilities) BufferedCancelIndicator(org.eclipse.xtext.util.BufferedCancelIndicator) LanguageClient(org.eclipse.lsp4j.services.LanguageClient) Inject(com.google.inject.Inject) WorkspaceClientCapabilities(org.eclipse.lsp4j.WorkspaceClientCapabilities) TextDocumentIdentifier(org.eclipse.lsp4j.TextDocumentIdentifier) ICodeLensService(org.eclipse.xtext.ide.server.codelens.ICodeLensService) IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) FoldingRangeRequestParams(org.eclipse.lsp4j.FoldingRangeRequestParams) Logger(org.apache.log4j.Logger) CodeLens(org.eclipse.lsp4j.CodeLens) DidChangeWorkspaceFoldersParams(org.eclipse.lsp4j.DidChangeWorkspaceFoldersParams) IReferenceFinder(org.eclipse.xtext.findReferences.IReferenceFinder) Location(org.eclipse.lsp4j.Location) Either(org.eclipse.lsp4j.jsonrpc.messages.Either) TextDocumentClientCapabilities(org.eclipse.lsp4j.TextDocumentClientCapabilities) DidCloseTextDocumentParams(org.eclipse.lsp4j.DidCloseTextDocumentParams) Objects(com.google.common.base.Objects) CodeAction(org.eclipse.lsp4j.CodeAction) LinkedListMultimap(com.google.common.collect.LinkedListMultimap) TextDocumentPositionParams(org.eclipse.lsp4j.TextDocumentPositionParams) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) IDocumentSymbolService(org.eclipse.xtext.ide.server.symbol.IDocumentSymbolService) PrepareRenameParams(org.eclipse.lsp4j.PrepareRenameParams) ICodeLensResolver(org.eclipse.xtext.ide.server.codelens.ICodeLensResolver) FoldingRangeService(org.eclipse.xtext.ide.server.folding.FoldingRangeService) DefinitionParams(org.eclipse.lsp4j.DefinitionParams) ServerCapabilities(org.eclipse.lsp4j.ServerCapabilities) CompletionItem(org.eclipse.lsp4j.CompletionItem) RenameCapabilities(org.eclipse.lsp4j.RenameCapabilities) List(java.util.List) Command(org.eclipse.lsp4j.Command) IDocumentHighlightService(org.eclipse.xtext.ide.server.occurrences.IDocumentHighlightService) WorkspaceSymbolService(org.eclipse.xtext.ide.server.symbol.WorkspaceSymbolService) DidOpenTextDocumentParams(org.eclipse.lsp4j.DidOpenTextDocumentParams) InitializeParams(org.eclipse.lsp4j.InitializeParams) WorkspaceFoldersOptions(org.eclipse.lsp4j.WorkspaceFoldersOptions) Buildable(org.eclipse.xtext.ide.server.BuildManager.Buildable) CompletionParams(org.eclipse.lsp4j.CompletionParams) DocumentSymbolParams(org.eclipse.lsp4j.DocumentSymbolParams) CompletableFuture(java.util.concurrent.CompletableFuture) Range(org.eclipse.lsp4j.Range) DocumentSymbolCapabilities(org.eclipse.lsp4j.DocumentSymbolCapabilities) Multimap(com.google.common.collect.Multimap) Function(java.util.function.Function) SymbolInformation(org.eclipse.lsp4j.SymbolInformation) CodeActionParams(org.eclipse.lsp4j.CodeActionParams) ExecuteCommandCapabilities(org.eclipse.lsp4j.ExecuteCommandCapabilities) ImmutableList(com.google.common.collect.ImmutableList) ExecuteCommandParams(org.eclipse.lsp4j.ExecuteCommandParams) CancelIndicator(org.eclipse.xtext.util.CancelIndicator) Position(org.eclipse.lsp4j.Position) CodeLensParams(org.eclipse.lsp4j.CodeLensParams) CompletionList(org.eclipse.lsp4j.CompletionList) DidChangeConfigurationParams(org.eclipse.lsp4j.DidChangeConfigurationParams) TextDocumentSyncKind(org.eclipse.lsp4j.TextDocumentSyncKind) InitializedParams(org.eclipse.lsp4j.InitializedParams) Severity(org.eclipse.xtext.diagnostics.Severity) FoldingRangeCapabilities(org.eclipse.lsp4j.FoldingRangeCapabilities) WorkspaceServerCapabilities(org.eclipse.lsp4j.WorkspaceServerCapabilities) ExecutableCommandRegistry(org.eclipse.xtext.ide.server.commands.ExecutableCommandRegistry) JsonRpcMethodProvider(org.eclipse.lsp4j.jsonrpc.json.JsonRpcMethodProvider) RequestManager(org.eclipse.xtext.ide.server.concurrent.RequestManager) WorkspaceResourceAccess(org.eclipse.xtext.ide.server.findReferences.WorkspaceResourceAccess) Collections(java.util.Collections) DocumentSymbol(org.eclipse.lsp4j.DocumentSymbol) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) ReferenceParams(org.eclipse.lsp4j.ReferenceParams) ICodeLensResolver(org.eclipse.xtext.ide.server.codelens.ICodeLensResolver) RenameOptions(org.eclipse.lsp4j.RenameOptions) RenameCapabilities(org.eclipse.lsp4j.RenameCapabilities) ICodeActionService2(org.eclipse.xtext.ide.server.codeActions.ICodeActionService2) ClientCapabilities(org.eclipse.lsp4j.ClientCapabilities) WorkspaceClientCapabilities(org.eclipse.lsp4j.WorkspaceClientCapabilities) TextDocumentClientCapabilities(org.eclipse.lsp4j.TextDocumentClientCapabilities) TextDocumentClientCapabilities(org.eclipse.lsp4j.TextDocumentClientCapabilities) WorkspaceFoldersOptions(org.eclipse.lsp4j.WorkspaceFoldersOptions) FoldingRangeService(org.eclipse.xtext.ide.server.folding.FoldingRangeService) WorkspaceServerCapabilities(org.eclipse.lsp4j.WorkspaceServerCapabilities) CompletionOptions(org.eclipse.lsp4j.CompletionOptions) WorkspaceClientCapabilities(org.eclipse.lsp4j.WorkspaceClientCapabilities) SignatureHelpOptions(org.eclipse.lsp4j.SignatureHelpOptions) IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider) FoldingRangeCapabilities(org.eclipse.lsp4j.FoldingRangeCapabilities) IRenameService2(org.eclipse.xtext.ide.server.rename.IRenameService2) ServerCapabilities(org.eclipse.lsp4j.ServerCapabilities) WorkspaceServerCapabilities(org.eclipse.lsp4j.WorkspaceServerCapabilities) CodeLensOptions(org.eclipse.lsp4j.CodeLensOptions) ExecuteCommandCapabilities(org.eclipse.lsp4j.ExecuteCommandCapabilities) ExecuteCommandOptions(org.eclipse.lsp4j.ExecuteCommandOptions)

Example 5 with CompletionOptions

use of org.eclipse.lsp4j.CompletionOptions in project ballerina by ballerina-lang.

the class BallerinaLanguageServer method initialize.

public CompletableFuture<InitializeResult> initialize(InitializeParams params) {
    final InitializeResult res = new InitializeResult(new ServerCapabilities());
    final SignatureHelpOptions signatureHelpOptions = new SignatureHelpOptions(Arrays.asList("(", ","));
    final List<String> commandList = new ArrayList<>(Arrays.asList(CommandConstants.CMD_IMPORT_PACKAGE, CommandConstants.CMD_ADD_DOCUMENTATION, CommandConstants.CMD_ADD_ALL_DOC));
    final ExecuteCommandOptions executeCommandOptions = new ExecuteCommandOptions(commandList);
    final CompletionOptions completionOptions = new CompletionOptions();
    completionOptions.setTriggerCharacters(Arrays.asList(":", ".", ">"));
    res.getCapabilities().setCompletionProvider(completionOptions);
    res.getCapabilities().setTextDocumentSync(TextDocumentSyncKind.Full);
    res.getCapabilities().setSignatureHelpProvider(signatureHelpOptions);
    res.getCapabilities().setHoverProvider(true);
    res.getCapabilities().setDocumentSymbolProvider(true);
    res.getCapabilities().setDefinitionProvider(true);
    res.getCapabilities().setReferencesProvider(true);
    res.getCapabilities().setCodeActionProvider(true);
    res.getCapabilities().setExecuteCommandProvider(executeCommandOptions);
    res.getCapabilities().setDocumentFormattingProvider(true);
    res.getCapabilities().setRenameProvider(true);
    return CompletableFuture.supplyAsync(() -> res);
}
Also used : CompletionOptions(org.eclipse.lsp4j.CompletionOptions) SignatureHelpOptions(org.eclipse.lsp4j.SignatureHelpOptions) InitializeResult(org.eclipse.lsp4j.InitializeResult) ArrayList(java.util.ArrayList) ServerCapabilities(org.eclipse.lsp4j.ServerCapabilities) ExecuteCommandOptions(org.eclipse.lsp4j.ExecuteCommandOptions)

Aggregations

CompletionOptions (org.eclipse.lsp4j.CompletionOptions)5 ServerCapabilities (org.eclipse.lsp4j.ServerCapabilities)5 ExecuteCommandOptions (org.eclipse.lsp4j.ExecuteCommandOptions)4 InitializeResult (org.eclipse.lsp4j.InitializeResult)4 ArrayList (java.util.ArrayList)3 CodeLensOptions (org.eclipse.lsp4j.CodeLensOptions)3 SignatureHelpOptions (org.eclipse.lsp4j.SignatureHelpOptions)3 WorkspaceFoldersOptions (org.eclipse.lsp4j.WorkspaceFoldersOptions)3 WorkspaceServerCapabilities (org.eclipse.lsp4j.WorkspaceServerCapabilities)3 Map (java.util.Map)2 ClientCapabilities (org.eclipse.lsp4j.ClientCapabilities)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