Search in sources :

Example 1 with ExecuteCommandOptions

use of org.graalvm.tools.lsp.server.types.ExecuteCommandOptions 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)

Aggregations

JSONObject (com.oracle.truffle.tools.utils.json.JSONObject)1 CodeLensOptions (org.graalvm.tools.lsp.server.types.CodeLensOptions)1 CompletionOptions (org.graalvm.tools.lsp.server.types.CompletionOptions)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 TextDocumentSyncOptions (org.graalvm.tools.lsp.server.types.TextDocumentSyncOptions)1