зеркало из https://github.com/dotnet/razor.git
Merge pull request #7986 from davidwengier/FixDiagnostics
This commit is contained in:
Коммит
1b06147708
|
@ -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;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче