public override ServerCapabilities GetCapabilities(ClientCapabilities clientCapabilities)
        {
            // If the LSP editor feature flag is enabled advertise support for LSP features here so they are available locally and remote.
            var isLspEditorEnabled = GlobalOptions.GetOption(LspOptions.LspEditorFeatureFlag);

            var serverCapabilities = isLspEditorEnabled
                ? (VSInternalServerCapabilities)_defaultCapabilitiesProvider.GetCapabilities(clientCapabilities)
                : new VSInternalServerCapabilities()
            {
                // Even if the flag is off, we want to include text sync capabilities.
                TextDocumentSync = new TextDocumentSyncOptions
                {
                    Change    = TextDocumentSyncKind.Incremental,
                    OpenClose = true,
                },
            };

            serverCapabilities.ProjectContextProvider = true;
            serverCapabilities.BreakableRangeProvider = true;

            var isPullDiagnostics = GlobalOptions.IsPullDiagnostics(InternalDiagnosticsOptions.NormalDiagnosticMode);

            if (isPullDiagnostics)
            {
                serverCapabilities.SupportsDiagnosticRequests     = true;
                serverCapabilities.MultipleContextSupportProvider = new VSInternalMultipleContextFeatures {
                    SupportsMultipleContextsDiagnostics = true
                };
            }

            // This capability is always enabled as we provide cntrl+Q VS search only via LSP in ever scenario.
            serverCapabilities.WorkspaceSymbolProvider = true;
            // This capability prevents NavigateTo (cntrl+,) from using LSP symbol search when the server also supports WorkspaceSymbolProvider.
            // Since WorkspaceSymbolProvider=true always to allow cntrl+Q VS search to function, we set DisableGoToWorkspaceSymbols=true
            // when not running the experimental LSP editor.  This ensures NavigateTo uses the existing editor APIs.
            // However, when the experimental LSP editor is enabled we want LSP to power NavigateTo, so we set DisableGoToWorkspaceSymbols=false.
            serverCapabilities.DisableGoToWorkspaceSymbols = !isLspEditorEnabled;

            var isLspSemanticTokensEnabled = GlobalOptions.GetOption(LspOptions.LspSemanticTokensFeatureFlag);

            if (isLspSemanticTokensEnabled)
            {
                // Using only range handling has shown to be more performant than using a combination of full/edits/range handling,
                // especially for larger files. With range handling, we only need to compute tokens for whatever is in view, while
                // with full/edits handling we need to compute tokens for the entire file and then potentially run a diff between
                // the old and new tokens.
                serverCapabilities.SemanticTokensOptions = new SemanticTokensOptions
                {
                    Full   = false,
                    Range  = true,
                    Legend = new SemanticTokensLegend
                    {
                        TokenTypes     = SemanticTokenTypes.AllTypes.Concat(SemanticTokensHelpers.RoslynCustomTokenTypes).ToArray(),
                        TokenModifiers = new string[] { SemanticTokenModifiers.Static }
                    }
                };
            }

            return(serverCapabilities);
        }
示例#2
0
        public override ServerCapabilities GetCapabilities(ClientCapabilities clientCapabilities)
        {
            var serverCapabilities = new VSInternalServerCapabilities();

            // If the LSP editor feature flag is enabled advertise support for LSP features here so they are available locally and remote.
            var isLspEditorEnabled = GlobalOptions.GetOption(LspOptions.LspEditorFeatureFlag);

            if (isLspEditorEnabled)
            {
                serverCapabilities = (VSInternalServerCapabilities)_defaultCapabilitiesProvider.GetCapabilities(clientCapabilities);
            }
            else
            {
                // Even if the flag is off, we want to include text sync capabilities.
                serverCapabilities.TextDocumentSync = new TextDocumentSyncOptions
                {
                    Change    = TextDocumentSyncKind.Incremental,
                    OpenClose = true,
                };
            }

            serverCapabilities.SupportsDiagnosticRequests = GlobalOptions.IsPullDiagnostics(InternalDiagnosticsOptions.NormalDiagnosticMode);

            // This capability is always enabled as we provide cntrl+Q VS search only via LSP in ever scenario.
            serverCapabilities.WorkspaceSymbolProvider = true;
            // This capability prevents NavigateTo (cntrl+,) from using LSP symbol search when the server also supports WorkspaceSymbolProvider.
            // Since WorkspaceSymbolProvider=true always to allow cntrl+Q VS search to function, we set DisableGoToWorkspaceSymbols=true
            // when not running the experimental LSP editor.  This ensures NavigateTo uses the existing editor APIs.
            // However, when the experimental LSP editor is enabled we want LSP to power NavigateTo, so we set DisableGoToWorkspaceSymbols=false.
            serverCapabilities.DisableGoToWorkspaceSymbols = !isLspEditorEnabled;

            return(serverCapabilities);
        }
        public IIncrementalAnalyzer CreateIncrementalAnalyzer(Workspace workspace)
        {
            if (GlobalOptions.IsPullDiagnostics(InternalDiagnosticsOptions.NormalDiagnosticMode))
            {
                // We rely on LSP to query us for diagnostics when things have changed and poll us for changes that might
                // have happened to the project or closed files outside of VS.
                // However, we still need to create the analyzer so that the map contains the analyzer to run when pull diagnostics asks.
                _ = _map.GetValue(workspace, _createIncrementalAnalyzer);

                return(NoOpIncrementalAnalyzer.Instance);
            }

            return(_map.GetValue(workspace, _createIncrementalAnalyzer));
        }
示例#4
0
        public override ServerCapabilities GetCapabilities(ClientCapabilities clientCapabilities)
        {
            var capabilities = _defaultCapabilitiesProvider.GetCapabilities(clientCapabilities);

            // Razor doesn't use workspace symbols, so disable to prevent duplicate results (with LiveshareLanguageClient) in liveshare.
            capabilities.WorkspaceSymbolProvider = false;

            if (capabilities is VSInternalServerCapabilities vsServerCapabilities)
            {
                vsServerCapabilities.SupportsDiagnosticRequests = GlobalOptions.IsPullDiagnostics(InternalDiagnosticsOptions.RazorDiagnosticMode);
                return(vsServerCapabilities);
            }

            return(capabilities);
        }
        public override ServerCapabilities GetCapabilities(ClientCapabilities clientCapabilities)
        {
            var isLspEditorEnabled = GlobalOptions.GetOption(LspOptions.LspEditorFeatureFlag);

            // If the preview feature flag to turn on the LSP editor in local scenarios is on, advertise no capabilities for this Live Share
            // LSP server as LSP requests will be serviced by the AlwaysActiveInProcLanguageClient in both local and remote scenarios.
            if (isLspEditorEnabled)
            {
                return(new VSServerCapabilities
                {
                    TextDocumentSync = new TextDocumentSyncOptions
                    {
                        OpenClose = false,
                        Change = TextDocumentSyncKind.None,
                    }
                });
            }

            var defaultCapabilities = _experimentalCapabilitiesProvider.GetCapabilities(clientCapabilities);

            // If the LSP semantic tokens feature flag is enabled, advertise no semantic tokens capabilities for this Live Share
            // LSP server as LSP semantic tokens requests will be serviced by the AlwaysActiveInProcLanguageClient in both local and
            // remote scenarios.
            var isLspSemanticTokenEnabled = GlobalOptions.GetOption(LspOptions.LspSemanticTokensFeatureFlag);

            if (isLspSemanticTokenEnabled)
            {
                defaultCapabilities.SemanticTokensOptions = null;
            }

            // When the lsp pull diagnostics feature flag is enabled we do not advertise pull diagnostics capabilities from here
            // as the AlwaysActivateInProcLanguageClient will provide pull diagnostics both locally and remote.
            var isPullDiagnosticsEnabled = GlobalOptions.IsPullDiagnostics(InternalDiagnosticsOptions.NormalDiagnosticMode);

            if (!isPullDiagnosticsEnabled)
            {
                // Pull diagnostics isn't enabled, let the live share server provide pull diagnostics.
                ((VSInternalServerCapabilities)defaultCapabilities).SupportsDiagnosticRequests = true;
            }

            return(defaultCapabilities);
        }
示例#6
0
        public override ServerCapabilities GetCapabilities(ClientCapabilities clientCapabilities)
        {
            var serverCapabilities = GetTypeScriptServerCapabilities(clientCapabilities);

            serverCapabilities.TextDocumentSync = new TextDocumentSyncOptions
            {
                Change    = TextDocumentSyncKind.Incremental,
                OpenClose = true,
            };

            serverCapabilities.ProjectContextProvider = true;

            var isPullDiagnostics = GlobalOptions.IsPullDiagnostics(InternalDiagnosticsOptions.NormalDiagnosticMode);

            if (isPullDiagnostics)
            {
                serverCapabilities.SupportsDiagnosticRequests = true;
            }

            return(serverCapabilities);
        }