Search in sources :

Example 1 with CompletionOptions

use of org.graalvm.tools.lsp.server.types.CompletionOptions in project graal by oracle.

the class CompletionTest method setTriggerCharacters.

private void setTriggerCharacters() {
    ServerCapabilities capabilities = ServerCapabilities.create();
    CompletionOptions completionProvider = CompletionOptions.create();
    completionProvider.setTriggerCharacters(Collections.singletonList("."));
    capabilities.setCompletionProvider(completionProvider);
    truffleAdapter.setServerCapabilities("sl", capabilities);
}
Also used : CompletionOptions(org.graalvm.tools.lsp.server.types.CompletionOptions) ServerCapabilities(org.graalvm.tools.lsp.server.types.ServerCapabilities)

Example 2 with CompletionOptions

use of org.graalvm.tools.lsp.server.types.CompletionOptions in project graal by oracle.

the class DelegateServers method supportsMethod.

static boolean supportsMethod(String method, JSONObject params, ServerCapabilities capabilities) {
    Object capability;
    switch(method) {
        case "textDocument/codeAction":
            capability = capabilities.getCodeActionProvider();
            break;
        case "textDocument/codeLens":
            capability = capabilities.getCodeLensProvider();
            break;
        case "codeLens/resolve":
            CodeLensOptions clp = capabilities.getCodeLensProvider();
            capability = (clp != null) ? clp.getResolveProvider() : null;
            break;
        case "textDocument/colorPresentation":
            capability = capabilities.getColorProvider();
            break;
        case "textDocument/completion":
            capability = capabilities.getCompletionProvider();
            break;
        case "completionItem/resolve":
            CompletionOptions co = capabilities.getCompletionProvider();
            capability = (co != null) ? co.getResolveProvider() : null;
            break;
        case "textDocument/declaration":
            capability = capabilities.getDeclarationProvider();
            break;
        case "textDocument/definition":
            capability = capabilities.getDefinitionProvider();
            break;
        case "textDocument/formatting":
            capability = capabilities.getDocumentFormattingProvider();
            break;
        case "textDocument/documentHighlight":
            capability = capabilities.getDocumentHighlightProvider();
            break;
        case "textDocument/documentLink":
            capability = capabilities.getDocumentLinkProvider();
            break;
        case "documentLink/resolve":
            DocumentLinkOptions dlo = capabilities.getDocumentLinkProvider();
            capability = (dlo != null) ? dlo.getResolveProvider() : null;
            break;
        case "textDocument/onTypeFormatting":
            capability = capabilities.getDocumentOnTypeFormattingProvider();
            break;
        case "textDocument/rangeFormatting":
            capability = capabilities.getDocumentRangeFormattingProvider();
            break;
        case "textDocument/documentSymbol":
            capability = capabilities.getDocumentSymbolProvider();
            break;
        case "workspace/executeCommand":
            ExecuteCommandOptions eco = capabilities.getExecuteCommandProvider();
            return eco.getCommands().contains(params.getString("command"));
        case "textDocument/foldingRange":
            capability = capabilities.getFoldingRangeProvider();
            break;
        case "textDocument/hover":
            capability = capabilities.getHoverProvider();
            break;
        case "textDocument/implementation":
            capability = capabilities.getImplementationProvider();
            break;
        case "textDocument/references":
            capability = capabilities.getReferencesProvider();
            break;
        case "textDocument/rename":
            capability = capabilities.getRenameProvider();
            break;
        case "textDocument/prepareRename":
            Object renameProvider = capabilities.getRenameProvider();
            capability = (renameProvider != null) ? ((RenameOptions) renameProvider).getPrepareProvider() : null;
            break;
        case "textDocument/signatureHelp":
            capability = capabilities.getSignatureHelpProvider();
            break;
        case "textDocument/didChange":
            capability = capabilities.getTextDocumentSync();
            if (capability instanceof TextDocumentSyncOptions) {
                capability = ((TextDocumentSyncOptions) capability).getChange();
            }
            capability = (capability == TextDocumentSyncKind.Full || capability == TextDocumentSyncKind.Incremental) ? true : null;
            break;
        case "textDocument/typeDefinition":
            capability = capabilities.getTypeDefinitionProvider();
            break;
        case "workspace/symbol":
            capability = capabilities.getWorkspaceSymbolProvider();
            break;
        default:
            return true;
    }
    return capability != null && !Boolean.FALSE.equals(capability);
}
Also used : CompletionOptions(org.graalvm.tools.lsp.server.types.CompletionOptions) RenameOptions(org.graalvm.tools.lsp.server.types.RenameOptions) TextDocumentSyncOptions(org.graalvm.tools.lsp.server.types.TextDocumentSyncOptions) DocumentLinkOptions(org.graalvm.tools.lsp.server.types.DocumentLinkOptions) JSONObject(com.oracle.truffle.tools.utils.json.JSONObject) CodeLensOptions(org.graalvm.tools.lsp.server.types.CodeLensOptions) ExecuteCommandOptions(org.graalvm.tools.lsp.server.types.ExecuteCommandOptions)

Example 3 with CompletionOptions

use of org.graalvm.tools.lsp.server.types.CompletionOptions in project graal by oracle.

the class TruffleAdapter method setServerCapabilities.

public void setServerCapabilities(String languageId, ServerCapabilities capabilities) {
    CompletionOptions completionProvider = capabilities.getCompletionProvider();
    if (completionProvider != null) {
        List<String> triggerCharacters = completionProvider.getTriggerCharacters();
        if (triggerCharacters != null) {
            completionTriggerCharacters.add(languageId, triggerCharacters);
        }
    }
    SignatureHelpOptions signatureHelpProvider = capabilities.getSignatureHelpProvider();
    if (signatureHelpProvider != null) {
        List<String> triggerCharacters = signatureHelpProvider.getTriggerCharacters();
        if (triggerCharacters != null) {
            signatureTriggerCharacters.add(languageId, triggerCharacters);
        }
    }
}
Also used : CompletionOptions(org.graalvm.tools.lsp.server.types.CompletionOptions) SignatureHelpOptions(org.graalvm.tools.lsp.server.types.SignatureHelpOptions)

Aggregations

CompletionOptions (org.graalvm.tools.lsp.server.types.CompletionOptions)3 JSONObject (com.oracle.truffle.tools.utils.json.JSONObject)1 CodeLensOptions (org.graalvm.tools.lsp.server.types.CodeLensOptions)1 DocumentLinkOptions (org.graalvm.tools.lsp.server.types.DocumentLinkOptions)1 ExecuteCommandOptions (org.graalvm.tools.lsp.server.types.ExecuteCommandOptions)1 RenameOptions (org.graalvm.tools.lsp.server.types.RenameOptions)1 ServerCapabilities (org.graalvm.tools.lsp.server.types.ServerCapabilities)1 SignatureHelpOptions (org.graalvm.tools.lsp.server.types.SignatureHelpOptions)1 TextDocumentSyncOptions (org.graalvm.tools.lsp.server.types.TextDocumentSyncOptions)1