Merge pull request #7986 from davidwengier/FixDiagnostics

This commit is contained in:
David Wengier 2022-12-02 14:38:57 +11:00 коммит произвёл GitHub
Родитель 17a44b008a 9f6a54c1fd
Коммит 1b06147708
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
8 изменённых файлов: 32 добавлений и 3 удалений

Просмотреть файл

@ -19,4 +19,6 @@ internal class DefaultLanguageServerFeatureOptions : LanguageServerFeatureOption
public override bool SingleServerCompletionSupport => false;
public override bool SingleServerSupport => false;
public override bool SingleServerDiagnosticsSupport => false;
}

Просмотреть файл

@ -49,13 +49,13 @@ internal class RazorPullDiagnosticsEndpoint
public async Task<IEnumerable<VSInternalDiagnosticReport>?> HandleRequestAsync(VSInternalDocumentDiagnosticsParams request, RazorRequestContext context, CancellationToken cancellationToken)
{
var documentContext = context.GetRequiredDocumentContext();
if (!_languageServerFeatureOptions.SingleServerSupport)
if (!_languageServerFeatureOptions.SingleServerDiagnosticsSupport)
{
return default;
}
var documentContext = context.GetRequiredDocumentContext();
var delegatedParams = new DelegatedDiagnosticParams(documentContext.Identifier);
var delegatedResponse = await _languageServer.SendRequestAsync<DelegatedDiagnosticParams, IEnumerable<VSInternalDiagnosticReport>>(

Просмотреть файл

@ -19,6 +19,8 @@ internal abstract class LanguageServerFeatureOptions
public abstract bool SingleServerSupport { get; }
public abstract bool SingleServerDiagnosticsSupport { get; }
public string GetRazorCSharpFilePath(string razorFilePath) => razorFilePath + CSharpVirtualDocumentSuffix;
public string GetRazorHtmlFilePath(string razorFilePath) => razorFilePath + HtmlVirtualDocumentSuffix;

Просмотреть файл

@ -115,6 +115,10 @@ internal class InitializeHandler : IRequestHandler<InitializeParams, InitializeR
_initializeResult.Capabilities.ImplementationProvider = false;
((VSInternalServerCapabilities)_initializeResult.Capabilities).OnAutoInsertProvider = null;
}
if (_languageServerFeatureOptions.SingleServerDiagnosticsSupport)
{
((VSInternalServerCapabilities)_initializeResult.Capabilities).SupportsDiagnosticRequests = false;
}

Просмотреть файл

@ -14,10 +14,12 @@ internal class VisualStudioWindowsLanguageServerFeatureOptions : LanguageServerF
{
private const string SingleServerCompletionFeatureFlag = "Razor.LSP.SingleServerCompletion";
private const string SingleServerFeatureFlag = "Razor.LSP.SingleServer";
private const string SingleServerDiagnosticsFeatureFlag = "Razor.LSP.SingleServerDiagnostics";
private readonly LSPEditorFeatureDetector _lspEditorFeatureDetector;
private readonly Lazy<bool> _singleServerCompletionSupport;
private readonly Lazy<bool> _singleServerSupport;
private readonly Lazy<bool> _singleServerDiagnosticsSupport;
[ImportingConstructor]
public VisualStudioWindowsLanguageServerFeatureOptions(LSPEditorFeatureDetector lspEditorFeatureDetector)
@ -42,6 +44,13 @@ internal class VisualStudioWindowsLanguageServerFeatureOptions : LanguageServerF
var singleServerEnabled = featureFlags.IsFeatureEnabled(SingleServerFeatureFlag, defaultValue: false);
return singleServerEnabled;
});
_singleServerDiagnosticsSupport = new Lazy<bool>(() =>
{
var featureFlags = (IVsFeatureFlags)AsyncPackage.GetGlobalService(typeof(SVsFeatureFlags));
var singleServerDiagnosticsEnabled = featureFlags.IsFeatureEnabled(SingleServerDiagnosticsFeatureFlag, defaultValue: false);
return singleServerDiagnosticsEnabled;
});
}
// We don't currently support file creation operations on VS Codespaces or VS Liveshare
@ -58,5 +67,7 @@ internal class VisualStudioWindowsLanguageServerFeatureOptions : LanguageServerF
public override bool SingleServerSupport => _singleServerSupport.Value;
public override bool SingleServerDiagnosticsSupport => _singleServerDiagnosticsSupport.Value;
private bool IsCodespacesOrLiveshare => _lspEditorFeatureDetector.IsRemoteClient() || _lspEditorFeatureDetector.IsLiveShareHost();
}

Просмотреть файл

@ -37,6 +37,8 @@ internal class VisualStudioMacLanguageServerFeatureOptions : LanguageServerFeatu
public override bool SingleServerSupport => false;
public override bool SingleServerDiagnosticsSupport => false;
private bool IsCodespacesOrLiveshare => _lspEditorFeatureDetector.IsRemoteClient() || _lspEditorFeatureDetector.IsLiveShareHost();
}

Просмотреть файл

@ -53,4 +53,10 @@
"Description"="Enable single server support when editing Razor (ASP.NET Core)."
"Value"=dword:00000001
"Title"="Enable enhanced Razor LSP server (requires restart)"
"PreviewPaneChannels"="IntPreview,int.main"
[$RootKey$\FeatureFlags\Razor\LSP\SingleServerDiagnostics]
"Description"="Enable single server diagnostics support when editing Razor (ASP.NET Core)."
"Value"=dword:00000000
"Title"="Enable enhanced Razor LSP diagnostics (requires restart)"
"PreviewPaneChannels"="IntPreview,int.main"

Просмотреть файл

@ -24,4 +24,6 @@ internal class TestLanguageServerFeatureOptions : LanguageServerFeatureOptions
public override bool SingleServerCompletionSupport => false;
public override bool SingleServerSupport => false;
public override bool SingleServerDiagnosticsSupport => false;
}