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 = Workspace.Services.GetRequiredService <IExperimentationService>().IsExperimentEnabled(VisualStudioWorkspaceContextService.LspEditorFeatureFlagName);

            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 = Workspace.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 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;

            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);
        }
        private static VSServerCapabilities GetVSServerCapabilities()
        {
            var vsServerCapabilities = new VSInternalServerCapabilities();

            vsServerCapabilities.OnAutoInsertProvider = new VSInternalDocumentOnAutoInsertOptions {
                TriggerCharacters = new[] { "'", "/", "\n" }
            };
            vsServerCapabilities.DocumentHighlightProvider = true;
            vsServerCapabilities.ProjectContextProvider    = true;

            // Diagnostic requests are only supported from PullDiagnosticsInProcLanguageClient.
            vsServerCapabilities.SupportsDiagnosticRequests = false;
            return(vsServerCapabilities);
        }
        public void Resolve_PullDiagnostics_ReturnsTrue()
        {
            // Arrange
            var methodName   = VSInternalMethods.DocumentPullDiagnosticName;
            var capabilities = new VSInternalServerCapabilities()
            {
                SupportsDiagnosticRequests = true,
            };
            var jobjectCapabilities = JObject.FromObject(capabilities);
            var filter = Resolver.Resolve(methodName);

            // Act
            var result = filter(jobjectCapabilities);

            // Assert
            Assert.True(result);
        }
        public void Resolve_OnAutoInsert_ReturnsTrue()
        {
            // Arrange
            var methodName   = VSInternalMethods.OnAutoInsertName;
            var capabilities = new VSInternalServerCapabilities()
            {
                OnAutoInsertProvider = new VSInternalDocumentOnAutoInsertOptions(),
            };
            var jobjectCapabilities = JObject.FromObject(capabilities);
            var filter = Resolver.Resolve(methodName);

            // Act
            var result = filter(jobjectCapabilities);

            // Assert
            Assert.True(result);
        }
        public void Resolve_MSReference_ReturnsTrue()
        {
            // Arrange
            var methodName   = VSInternalMethods.DocumentReferencesName;
            var capabilities = new VSInternalServerCapabilities()
            {
                MSReferencesProvider = true,
            };
            var jobjectCapabilities = JObject.FromObject(capabilities);
            var filter = Resolver.Resolve(methodName);

            // Act
            var result = filter(jobjectCapabilities);

            // Assert
            Assert.True(result);
        }