Search in sources :

Example 1 with SemanticTokensServerFull

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

the class InitHandler method registerCapabilities.

@Override
public void registerCapabilities(InitializeResult initializeResult) {
    ServerCapabilities capabilities = new ServerCapabilities();
    if (!preferenceManager.getClientPreferences().isCompletionDynamicRegistered()) {
        capabilities.setCompletionProvider(CompletionHandler.DEFAULT_COMPLETION_OPTIONS);
    }
    if (!preferenceManager.getClientPreferences().isFormattingDynamicRegistrationSupported()) {
        capabilities.setDocumentFormattingProvider(Boolean.TRUE);
    }
    if (!preferenceManager.getClientPreferences().isRangeFormattingDynamicRegistrationSupported()) {
        capabilities.setDocumentRangeFormattingProvider(Boolean.TRUE);
    }
    if (!preferenceManager.getClientPreferences().isOnTypeFormattingDynamicRegistrationSupported()) {
        capabilities.setDocumentOnTypeFormattingProvider(new DocumentOnTypeFormattingOptions(";", Arrays.asList("\n", "}")));
    }
    if (!preferenceManager.getClientPreferences().isCodeLensDynamicRegistrationSupported()) {
        capabilities.setCodeLensProvider(new CodeLensOptions(true));
    }
    if (!preferenceManager.getClientPreferences().isSignatureHelpDynamicRegistrationSupported()) {
        capabilities.setSignatureHelpProvider(SignatureHelpHandler.createOptions());
    }
    if (!preferenceManager.getClientPreferences().isRenameDynamicRegistrationSupported()) {
        capabilities.setRenameProvider(RenameHandler.createOptions());
    }
    if (!preferenceManager.getClientPreferences().isCodeActionDynamicRegistered()) {
        if (preferenceManager.getClientPreferences().isResolveCodeActionSupported()) {
            CodeActionOptions codeActionOptions = new CodeActionOptions();
            codeActionOptions.setResolveProvider(Boolean.TRUE);
            capabilities.setCodeActionProvider(codeActionOptions);
        } else {
            capabilities.setCodeActionProvider(Boolean.TRUE);
        }
    }
    if (!preferenceManager.getClientPreferences().isExecuteCommandDynamicRegistrationSupported()) {
        Set<String> commands = commandHandler.getAllCommands();
        if (!commands.isEmpty()) {
            capabilities.setExecuteCommandProvider(new ExecuteCommandOptions(new ArrayList<>(commands)));
        }
    } else {
        // Send static command at the startup - they remain registered all the time
        Set<String> staticCommands = commandHandler.getStaticCommands();
        if (!staticCommands.isEmpty()) {
            capabilities.setExecuteCommandProvider(new ExecuteCommandOptions(new ArrayList<>(staticCommands)));
        }
    }
    if (!preferenceManager.getClientPreferences().isWorkspaceSymbolDynamicRegistered()) {
        capabilities.setWorkspaceSymbolProvider(Boolean.TRUE);
    }
    if (!preferenceManager.getClientPreferences().isClientDocumentSymbolProviderRegistered() && !preferenceManager.getClientPreferences().isDocumentSymbolDynamicRegistered()) {
        capabilities.setDocumentSymbolProvider(Boolean.TRUE);
    }
    if (!preferenceManager.getClientPreferences().isDefinitionDynamicRegistered()) {
        capabilities.setDefinitionProvider(Boolean.TRUE);
    }
    if (!preferenceManager.getClientPreferences().isTypeDefinitionDynamicRegistered()) {
        capabilities.setTypeDefinitionProvider(Boolean.TRUE);
    }
    if (!preferenceManager.getClientPreferences().isClientHoverProviderRegistered() && !preferenceManager.getClientPreferences().isHoverDynamicRegistered()) {
        capabilities.setHoverProvider(Boolean.TRUE);
    }
    if (!preferenceManager.getClientPreferences().isReferencesDynamicRegistered()) {
        capabilities.setReferencesProvider(Boolean.TRUE);
    }
    if (!preferenceManager.getClientPreferences().isDocumentHighlightDynamicRegistered()) {
        capabilities.setDocumentHighlightProvider(Boolean.TRUE);
    }
    if (!preferenceManager.getClientPreferences().isFoldgingRangeDynamicRegistered()) {
        capabilities.setFoldingRangeProvider(Boolean.TRUE);
    }
    if (!preferenceManager.getClientPreferences().isImplementationDynamicRegistered()) {
        capabilities.setImplementationProvider(Boolean.TRUE);
    }
    if (!preferenceManager.getClientPreferences().isSelectionRangeDynamicRegistered()) {
        capabilities.setSelectionRangeProvider(Boolean.TRUE);
    }
    capabilities.setCallHierarchyProvider(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);
    SemanticTokensWithRegistrationOptions semanticTokensOptions = new SemanticTokensWithRegistrationOptions();
    semanticTokensOptions.setFull(new SemanticTokensServerFull(false));
    semanticTokensOptions.setRange(false);
    semanticTokensOptions.setDocumentSelector(List.of(new DocumentFilter("java", "file", null), new DocumentFilter("java", "jdt", null)));
    semanticTokensOptions.setLegend(SemanticTokensHandler.legend());
    capabilities.setSemanticTokensProvider(semanticTokensOptions);
    initializeResult.setCapabilities(capabilities);
}
Also used : TextDocumentSyncOptions(org.eclipse.lsp4j.TextDocumentSyncOptions) DocumentOnTypeFormattingOptions(org.eclipse.lsp4j.DocumentOnTypeFormattingOptions) ArrayList(java.util.ArrayList) DocumentFilter(org.eclipse.lsp4j.DocumentFilter) WorkspaceFoldersOptions(org.eclipse.lsp4j.WorkspaceFoldersOptions) WorkspaceServerCapabilities(org.eclipse.lsp4j.WorkspaceServerCapabilities) CodeActionOptions(org.eclipse.lsp4j.CodeActionOptions) ServerCapabilities(org.eclipse.lsp4j.ServerCapabilities) WorkspaceServerCapabilities(org.eclipse.lsp4j.WorkspaceServerCapabilities) CodeLensOptions(org.eclipse.lsp4j.CodeLensOptions) SaveOptions(org.eclipse.lsp4j.SaveOptions) SemanticTokensServerFull(org.eclipse.lsp4j.SemanticTokensServerFull) ExecuteCommandOptions(org.eclipse.lsp4j.ExecuteCommandOptions) SemanticTokensWithRegistrationOptions(org.eclipse.lsp4j.SemanticTokensWithRegistrationOptions)

Example 2 with SemanticTokensServerFull

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

the class SyntaxInitHandler method registerCapabilities.

@Override
public void registerCapabilities(InitializeResult initializeResult) {
    ServerCapabilities capabilities = new ServerCapabilities();
    if (!preferenceManager.getClientPreferences().isClientDocumentSymbolProviderRegistered() && !preferenceManager.getClientPreferences().isDocumentSymbolDynamicRegistered()) {
        capabilities.setDocumentSymbolProvider(Boolean.TRUE);
    }
    if (!preferenceManager.getClientPreferences().isDefinitionDynamicRegistered()) {
        capabilities.setDefinitionProvider(Boolean.TRUE);
    }
    if (!preferenceManager.getClientPreferences().isTypeDefinitionDynamicRegistered()) {
        capabilities.setTypeDefinitionProvider(Boolean.TRUE);
    }
    if (!preferenceManager.getClientPreferences().isFoldgingRangeDynamicRegistered()) {
        capabilities.setFoldingRangeProvider(Boolean.TRUE);
    }
    if (!preferenceManager.getClientPreferences().isSelectionRangeDynamicRegistered()) {
        capabilities.setSelectionRangeProvider(Boolean.TRUE);
    }
    if (!preferenceManager.getClientPreferences().isHoverDynamicRegistered()) {
        capabilities.setHoverProvider(Boolean.TRUE);
    }
    if (!preferenceManager.getClientPreferences().isCompletionDynamicRegistered()) {
        capabilities.setCompletionProvider(CompletionHandler.DEFAULT_COMPLETION_OPTIONS);
    }
    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);
    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);
    SemanticTokensWithRegistrationOptions semanticTokensOptions = new SemanticTokensWithRegistrationOptions();
    semanticTokensOptions.setFull(new SemanticTokensServerFull(false));
    semanticTokensOptions.setRange(false);
    semanticTokensOptions.setDocumentSelector(List.of(new DocumentFilter("java", "file", null), new DocumentFilter("java", "jdt", null)));
    semanticTokensOptions.setLegend(SemanticTokensHandler.legend());
    capabilities.setSemanticTokensProvider(semanticTokensOptions);
    initializeResult.setCapabilities(capabilities);
}
Also used : TextDocumentSyncOptions(org.eclipse.lsp4j.TextDocumentSyncOptions) ServerCapabilities(org.eclipse.lsp4j.ServerCapabilities) WorkspaceServerCapabilities(org.eclipse.lsp4j.WorkspaceServerCapabilities) SaveOptions(org.eclipse.lsp4j.SaveOptions) SemanticTokensServerFull(org.eclipse.lsp4j.SemanticTokensServerFull) DocumentFilter(org.eclipse.lsp4j.DocumentFilter) WorkspaceFoldersOptions(org.eclipse.lsp4j.WorkspaceFoldersOptions) WorkspaceServerCapabilities(org.eclipse.lsp4j.WorkspaceServerCapabilities) SemanticTokensWithRegistrationOptions(org.eclipse.lsp4j.SemanticTokensWithRegistrationOptions)

Example 3 with SemanticTokensServerFull

use of org.eclipse.lsp4j.SemanticTokensServerFull in project OberonEmulator by schierlm.

the class Server method fillCapabilities.

protected void fillCapabilities(ServerCapabilities cap, InitializeParams params) {
    cap.setTextDocumentSync(TextDocumentSyncKind.Full);
    cap.setSemanticTokensProvider(new SemanticTokensWithRegistrationOptions(new SemanticTokensLegend(Bridge.TOKEN_TYPES, Bridge.TOKEN_MODIFIERS), new SemanticTokensServerFull(false), false));
    cap.setDocumentSymbolProvider(new DocumentSymbolOptions("Oberon"));
    cap.setCompletionProvider(new CompletionOptions(false, null));
    cap.setDefinitionProvider(true);
    cap.setDocumentHighlightProvider(true);
    cap.setReferencesProvider(true);
    cap.setLinkedEditingRangeProvider(true);
    cap.setSignatureHelpProvider(new SignatureHelpOptions(Arrays.asList("("), Arrays.asList(",", ")")));
    cap.setFoldingRangeProvider(true);
    cap.setHoverProvider(true);
    cap.setRenameProvider(new RenameOptions(true));
    cap.setDocumentFormattingProvider(true);
    cap.setCallHierarchyProvider(true);
    CodeActionOptions cao = new CodeActionOptions(Arrays.asList(CodeActionKind.QuickFix));
    cao.setResolveProvider(true);
    cap.setCodeActionProvider(cao);
}
Also used : CompletionOptions(org.eclipse.lsp4j.CompletionOptions) RenameOptions(org.eclipse.lsp4j.RenameOptions) SignatureHelpOptions(org.eclipse.lsp4j.SignatureHelpOptions) DocumentSymbolOptions(org.eclipse.lsp4j.DocumentSymbolOptions) CodeActionOptions(org.eclipse.lsp4j.CodeActionOptions) SemanticTokensLegend(org.eclipse.lsp4j.SemanticTokensLegend) SemanticTokensServerFull(org.eclipse.lsp4j.SemanticTokensServerFull) SemanticTokensWithRegistrationOptions(org.eclipse.lsp4j.SemanticTokensWithRegistrationOptions)

Aggregations

SemanticTokensServerFull (org.eclipse.lsp4j.SemanticTokensServerFull)3 SemanticTokensWithRegistrationOptions (org.eclipse.lsp4j.SemanticTokensWithRegistrationOptions)3 CodeActionOptions (org.eclipse.lsp4j.CodeActionOptions)2 DocumentFilter (org.eclipse.lsp4j.DocumentFilter)2 SaveOptions (org.eclipse.lsp4j.SaveOptions)2 ServerCapabilities (org.eclipse.lsp4j.ServerCapabilities)2 TextDocumentSyncOptions (org.eclipse.lsp4j.TextDocumentSyncOptions)2 WorkspaceFoldersOptions (org.eclipse.lsp4j.WorkspaceFoldersOptions)2 WorkspaceServerCapabilities (org.eclipse.lsp4j.WorkspaceServerCapabilities)2 ArrayList (java.util.ArrayList)1 CodeLensOptions (org.eclipse.lsp4j.CodeLensOptions)1 CompletionOptions (org.eclipse.lsp4j.CompletionOptions)1 DocumentOnTypeFormattingOptions (org.eclipse.lsp4j.DocumentOnTypeFormattingOptions)1 DocumentSymbolOptions (org.eclipse.lsp4j.DocumentSymbolOptions)1 ExecuteCommandOptions (org.eclipse.lsp4j.ExecuteCommandOptions)1 RenameOptions (org.eclipse.lsp4j.RenameOptions)1 SemanticTokensLegend (org.eclipse.lsp4j.SemanticTokensLegend)1 SignatureHelpOptions (org.eclipse.lsp4j.SignatureHelpOptions)1