/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/EditorFeatures/Core/LanguageServer/LiveShareCapabilitiesProvider.cs
50 строк
2 KB
David Barbet
Refactor SG documents to use LSP textDocumentContent
15 апр 2026, 21:35
15 апр 2026, 21:35
a26b299
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Composition; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.LanguageServer; using Microsoft.CodeAnalysis.LanguageServer.Handler; using Microsoft.CodeAnalysis.Options; using Microsoft.CommonLanguageServerProtocol.Framework; using Roslyn.LanguageServer.Protocol; [ExportCSharpVisualBasicStatelessLspService(typeof(ICapabilitiesProvider), WellKnownLspServerKinds.LiveShareLspServer), Shared] [method: ImportingConstructor] [method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] internal sealed class LiveShareCapabilitiesProvider(DefaultCapabilitiesProvider defaultCapabilitiesProvider, IGlobalOptionService globalOptionService) : ICapabilitiesProvider { public ServerCapabilities GetCapabilities(ClientCapabilities clientCapabilities, ILspServices lspServices) { var isLspEditorEnabled = globalOptionService.GetOption(LspOptionsStorage.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 = defaultCapabilitiesProvider.GetCapabilities(clientCapabilities, lspServices); // 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 = globalOptionService.GetOption(LspOptionsStorage.LspSemanticTokensFeatureFlag); if (isLspSemanticTokenEnabled) { defaultCapabilities.SemanticTokensOptions = null; } return defaultCapabilities; } }