Skip to content

Commit 3be97e6

Browse files
Remove unnecessary dependency in LSP handlers (#78356)
2 parents f7bbe5d + 668d57e commit 3be97e6

12 files changed

+45
-98
lines changed

src/EditorFeatures/Core/ExternalAccess/VSTypeScript/VSTypeScriptPullDiagnosticHandlerProvider.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,17 @@ namespace Microsoft.CodeAnalysis.ExternalAccess.VSTypeScript;
1717
[method: ImportingConstructor]
1818
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
1919
internal class VSTypeScriptDocumentPullDiagnosticHandlerFactory(
20-
IDiagnosticAnalyzerService analyzerService,
2120
IDiagnosticSourceManager diagnosticSourceManager,
2221
IDiagnosticsRefresher diagnosticsRefresher,
23-
IGlobalOptionService globalOptions) : DocumentPullDiagnosticHandlerFactory(analyzerService, diagnosticSourceManager, diagnosticsRefresher, globalOptions)
24-
{
25-
}
22+
IGlobalOptionService globalOptions)
23+
: DocumentPullDiagnosticHandlerFactory(diagnosticSourceManager, diagnosticsRefresher, globalOptions);
2624

2725
[ExportLspServiceFactory(typeof(WorkspacePullDiagnosticHandler), ProtocolConstants.TypeScriptLanguageContract), Shared]
2826
[method: ImportingConstructor]
2927
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
3028
internal class VSTypeScriptWorkspacePullDiagnosticHandler(
3129
LspWorkspaceRegistrationService registrationService,
32-
IDiagnosticAnalyzerService analyzerService,
3330
IDiagnosticSourceManager diagnosticSourceManager,
3431
IDiagnosticsRefresher diagnosticsRefresher,
35-
IGlobalOptionService globalOptions) : WorkspacePullDiagnosticHandlerFactory(registrationService, analyzerService, diagnosticSourceManager, diagnosticsRefresher, globalOptions)
36-
{
37-
}
32+
IGlobalOptionService globalOptions)
33+
: WorkspacePullDiagnosticHandlerFactory(registrationService, diagnosticSourceManager, diagnosticsRefresher, globalOptions);

src/LanguageServer/Protocol/Handler/Diagnostics/AbstractDocumentPullDiagnosticHandler.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@
1414
namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Diagnostics;
1515

1616
internal abstract class AbstractDocumentPullDiagnosticHandler<TDiagnosticsParams, TReport, TReturn>(
17-
IDiagnosticAnalyzerService diagnosticAnalyzerService,
1817
IDiagnosticsRefresher diagnosticRefresher,
1918
IDiagnosticSourceManager diagnosticSourceManager,
2019
IGlobalOptionService globalOptions)
2120
: AbstractPullDiagnosticHandler<TDiagnosticsParams, TReport, TReturn>(
22-
diagnosticAnalyzerService,
2321
diagnosticRefresher,
2422
globalOptions), ITextDocumentIdentifierHandler<TDiagnosticsParams, TextDocumentIdentifier?>
2523
where TDiagnosticsParams : IPartialResultParams<TReport>

src/LanguageServer/Protocol/Handler/Diagnostics/AbstractPullDiagnosticHandler.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Diagnostics;
2626
/// <typeparam name="TReport">The LSP type that is reported via IProgress</typeparam>
2727
/// <typeparam name="TReturn">The LSP type that is returned on completion of the request.</typeparam>
2828
internal abstract partial class AbstractPullDiagnosticHandler<TDiagnosticsParams, TReport, TReturn>(
29-
IDiagnosticAnalyzerService diagnosticAnalyzerService,
3029
IDiagnosticsRefresher diagnosticRefresher,
3130
IGlobalOptionService globalOptions)
3231
: ILspServiceRequestHandler<TDiagnosticsParams, TReturn?>
@@ -43,7 +42,6 @@ internal abstract partial class AbstractPullDiagnosticHandler<TDiagnosticsParams
4342
private readonly IDiagnosticsRefresher _diagnosticRefresher = diagnosticRefresher;
4443

4544
protected readonly IGlobalOptionService GlobalOptions = globalOptions;
46-
protected readonly IDiagnosticAnalyzerService DiagnosticAnalyzerService = diagnosticAnalyzerService;
4745

4846
/// <summary>
4947
/// Map of diagnostic category to the diagnostics cache for that category.

src/LanguageServer/Protocol/Handler/Diagnostics/AbstractWorkspacePullDiagnosticsHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ internal abstract class AbstractWorkspacePullDiagnosticsHandler<TDiagnosticsPara
3737
protected AbstractWorkspacePullDiagnosticsHandler(
3838
LspWorkspaceManager workspaceManager,
3939
LspWorkspaceRegistrationService registrationService,
40-
IDiagnosticAnalyzerService diagnosticAnalyzerService,
4140
IDiagnosticSourceManager diagnosticSourceManager,
4241
IDiagnosticsRefresher diagnosticRefresher,
43-
IGlobalOptionService globalOptions) : base(diagnosticAnalyzerService, diagnosticRefresher, globalOptions)
42+
IGlobalOptionService globalOptions)
43+
: base(diagnosticRefresher, globalOptions)
4444
{
4545
DiagnosticSourceManager = diagnosticSourceManager;
4646
_workspaceManager = workspaceManager;

src/LanguageServer/Protocol/Handler/Diagnostics/DocumentPullDiagnosticHandler.cs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,13 @@
1111
namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Diagnostics;
1212

1313
[Method(VSInternalMethods.DocumentPullDiagnosticName)]
14-
internal sealed partial class DocumentPullDiagnosticHandler
15-
: AbstractDocumentPullDiagnosticHandler<VSInternalDocumentDiagnosticsParams, VSInternalDiagnosticReport[], VSInternalDiagnosticReport[]>
14+
internal sealed partial class DocumentPullDiagnosticHandler(
15+
IDiagnosticSourceManager diagnosticSourceManager,
16+
IDiagnosticsRefresher diagnosticRefresher,
17+
IGlobalOptionService globalOptions)
18+
: AbstractDocumentPullDiagnosticHandler<VSInternalDocumentDiagnosticsParams, VSInternalDiagnosticReport[], VSInternalDiagnosticReport[]>(
19+
diagnosticRefresher, diagnosticSourceManager, globalOptions)
1620
{
17-
public DocumentPullDiagnosticHandler(
18-
IDiagnosticAnalyzerService analyzerService,
19-
IDiagnosticSourceManager diagnosticSourceManager,
20-
IDiagnosticsRefresher diagnosticRefresher,
21-
IGlobalOptionService globalOptions)
22-
: base(analyzerService, diagnosticRefresher, diagnosticSourceManager, globalOptions)
23-
{
24-
}
25-
2621
protected override string? GetRequestDiagnosticCategory(VSInternalDocumentDiagnosticsParams diagnosticsParams)
2722
=> diagnosticsParams.QueryingDiagnosticKind?.Value;
2823

src/LanguageServer/Protocol/Handler/Diagnostics/DocumentPullDiagnosticHandlerFactory.cs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,13 @@
1212
namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Diagnostics;
1313

1414
[ExportCSharpVisualBasicLspServiceFactory(typeof(DocumentPullDiagnosticHandler)), Shared]
15-
internal class DocumentPullDiagnosticHandlerFactory : ILspServiceFactory
15+
[method: ImportingConstructor]
16+
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
17+
internal class DocumentPullDiagnosticHandlerFactory(
18+
IDiagnosticSourceManager diagnosticSourceManager,
19+
IDiagnosticsRefresher diagnosticsRefresher,
20+
IGlobalOptionService globalOptions) : ILspServiceFactory
1621
{
17-
private readonly IDiagnosticAnalyzerService _analyzerService;
18-
private readonly IDiagnosticSourceManager _diagnosticSourceManager;
19-
private readonly IDiagnosticsRefresher _diagnosticsRefresher;
20-
private readonly IGlobalOptionService _globalOptions;
21-
22-
[ImportingConstructor]
23-
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
24-
public DocumentPullDiagnosticHandlerFactory(
25-
IDiagnosticAnalyzerService analyzerService,
26-
IDiagnosticSourceManager diagnosticSourceManager,
27-
IDiagnosticsRefresher diagnosticsRefresher,
28-
IGlobalOptionService globalOptions)
29-
{
30-
_analyzerService = analyzerService;
31-
_diagnosticSourceManager = diagnosticSourceManager;
32-
_diagnosticsRefresher = diagnosticsRefresher;
33-
_globalOptions = globalOptions;
34-
}
35-
3622
public ILspService CreateILspService(LspServices lspServices, WellKnownLspServerKinds serverKind)
37-
=> new DocumentPullDiagnosticHandler(_analyzerService, _diagnosticSourceManager, _diagnosticsRefresher, _globalOptions);
23+
=> new DocumentPullDiagnosticHandler(diagnosticSourceManager, diagnosticsRefresher, globalOptions);
3824
}

src/LanguageServer/Protocol/Handler/Diagnostics/Public/PublicDocumentPullDiagnosticHandlerFactory.cs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,16 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Diagnostics.Public;
1515
// by n DocumentDiagnosticPartialResult literals.
1616
// See https://github.com/microsoft/vscode-languageserver-node/blob/main/protocol/src/common/proposed.diagnostics.md#textDocument_diagnostic
1717
[ExportCSharpVisualBasicLspServiceFactory(typeof(PublicDocumentPullDiagnosticsHandler)), Shared]
18-
internal sealed class PublicDocumentPullDiagnosticHandlerFactory : ILspServiceFactory
18+
[method: ImportingConstructor]
19+
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
20+
internal sealed class PublicDocumentPullDiagnosticHandlerFactory(
21+
IDiagnosticSourceManager diagnosticSourceManager,
22+
IDiagnosticsRefresher diagnosticRefresher,
23+
IGlobalOptionService globalOptions) : ILspServiceFactory
1924
{
20-
private readonly IDiagnosticAnalyzerService _analyzerService;
21-
private readonly IDiagnosticSourceManager _diagnosticSourceManager;
22-
private readonly IDiagnosticsRefresher _diagnosticRefresher;
23-
private readonly IGlobalOptionService _globalOptions;
24-
25-
[ImportingConstructor]
26-
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
27-
public PublicDocumentPullDiagnosticHandlerFactory(
28-
IDiagnosticAnalyzerService analyzerService,
29-
IDiagnosticSourceManager diagnosticSourceManager,
30-
IDiagnosticsRefresher diagnosticRefresher,
31-
IGlobalOptionService globalOptions)
32-
{
33-
_analyzerService = analyzerService;
34-
_diagnosticSourceManager = diagnosticSourceManager;
35-
_diagnosticRefresher = diagnosticRefresher;
36-
_globalOptions = globalOptions;
37-
}
38-
3925
public ILspService CreateILspService(LspServices lspServices, WellKnownLspServerKinds serverKind)
4026
{
4127
var clientLanguageServerManager = lspServices.GetRequiredService<IClientLanguageServerManager>();
42-
return new PublicDocumentPullDiagnosticsHandler(clientLanguageServerManager, _analyzerService, _diagnosticSourceManager, _diagnosticRefresher, _globalOptions);
28+
return new PublicDocumentPullDiagnosticsHandler(clientLanguageServerManager, diagnosticSourceManager, diagnosticRefresher, globalOptions);
4329
}
4430
}

src/LanguageServer/Protocol/Handler/Diagnostics/Public/PublicDocumentPullDiagnosticsHandler.cs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,15 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Diagnostics.Public;
1818
using DocumentDiagnosticReport = SumType<RelatedFullDocumentDiagnosticReport, RelatedUnchangedDocumentDiagnosticReport>;
1919

2020
[Method(Methods.TextDocumentDiagnosticName)]
21-
internal sealed partial class PublicDocumentPullDiagnosticsHandler : AbstractDocumentPullDiagnosticHandler<DocumentDiagnosticParams, DocumentDiagnosticPartialReport, DocumentDiagnosticReport?>
21+
internal sealed partial class PublicDocumentPullDiagnosticsHandler(
22+
IClientLanguageServerManager clientLanguageServerManager,
23+
IDiagnosticSourceManager diagnosticSourceManager,
24+
IDiagnosticsRefresher diagnosticsRefresher,
25+
IGlobalOptionService globalOptions)
26+
: AbstractDocumentPullDiagnosticHandler<DocumentDiagnosticParams, DocumentDiagnosticPartialReport, DocumentDiagnosticReport?>(
27+
diagnosticsRefresher, diagnosticSourceManager, globalOptions)
2228
{
23-
private readonly IClientLanguageServerManager _clientLanguageServerManager;
24-
25-
public PublicDocumentPullDiagnosticsHandler(
26-
IClientLanguageServerManager clientLanguageServerManager,
27-
IDiagnosticAnalyzerService analyzerService,
28-
IDiagnosticSourceManager diagnosticSourceManager,
29-
IDiagnosticsRefresher diagnosticsRefresher,
30-
IGlobalOptionService globalOptions)
31-
: base(analyzerService, diagnosticsRefresher, diagnosticSourceManager, globalOptions)
32-
{
33-
_clientLanguageServerManager = clientLanguageServerManager;
34-
}
29+
private readonly IClientLanguageServerManager _clientLanguageServerManager = clientLanguageServerManager;
3530

3631
protected override string? GetRequestDiagnosticCategory(DocumentDiagnosticParams diagnosticsParams)
3732
=> diagnosticsParams.Identifier;

src/LanguageServer/Protocol/Handler/Diagnostics/Public/PublicWorkspacePullDiagnosticHandlerFactory.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Diagnostics.Public;
1616
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
1717
internal sealed class PublicWorkspacePullDiagnosticHandlerFactory(
1818
LspWorkspaceRegistrationService registrationService,
19-
IDiagnosticAnalyzerService analyzerService,
2019
IDiagnosticSourceManager diagnosticSourceManager,
2120
IDiagnosticsRefresher diagnosticsRefresher,
2221
IGlobalOptionService globalOptions) : ILspServiceFactory
2322
{
2423
public ILspService CreateILspService(LspServices lspServices, WellKnownLspServerKinds serverKind)
2524
{
2625
var workspaceManager = lspServices.GetRequiredService<LspWorkspaceManager>();
27-
return new PublicWorkspacePullDiagnosticsHandler(workspaceManager, registrationService, analyzerService, diagnosticSourceManager, diagnosticsRefresher, globalOptions);
26+
return new PublicWorkspacePullDiagnosticsHandler(workspaceManager, registrationService, diagnosticSourceManager, diagnosticsRefresher, globalOptions);
2827
}
2928
}

src/LanguageServer/Protocol/Handler/Diagnostics/Public/PublicWorkspacePullDiagnosticsHandler.cs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,15 @@ namespace Microsoft.CodeAnalysis.LanguageServer.Handler.Diagnostics.Public;
2020
using WorkspaceDiagnosticPartialReport = SumType<WorkspaceDiagnosticReport, WorkspaceDiagnosticReportPartialResult>;
2121

2222
[Method(Methods.WorkspaceDiagnosticName)]
23-
internal sealed partial class PublicWorkspacePullDiagnosticsHandler : AbstractWorkspacePullDiagnosticsHandler<WorkspaceDiagnosticParams, WorkspaceDiagnosticPartialReport, WorkspaceDiagnosticReport?>, IDisposable
23+
internal sealed partial class PublicWorkspacePullDiagnosticsHandler(
24+
LspWorkspaceManager workspaceManager,
25+
LspWorkspaceRegistrationService registrationService,
26+
IDiagnosticSourceManager diagnosticSourceManager,
27+
IDiagnosticsRefresher diagnosticRefresher,
28+
IGlobalOptionService globalOptions)
29+
: AbstractWorkspacePullDiagnosticsHandler<WorkspaceDiagnosticParams, WorkspaceDiagnosticPartialReport, WorkspaceDiagnosticReport?>(
30+
workspaceManager, registrationService, diagnosticSourceManager, diagnosticRefresher, globalOptions), IDisposable
2431
{
25-
public PublicWorkspacePullDiagnosticsHandler(
26-
LspWorkspaceManager workspaceManager,
27-
LspWorkspaceRegistrationService registrationService,
28-
IDiagnosticAnalyzerService analyzerService,
29-
IDiagnosticSourceManager diagnosticSourceManager,
30-
IDiagnosticsRefresher diagnosticRefresher,
31-
IGlobalOptionService globalOptions)
32-
: base(workspaceManager, registrationService, analyzerService, diagnosticSourceManager, diagnosticRefresher, globalOptions)
33-
{
34-
}
35-
3632
protected override string? GetRequestDiagnosticCategory(WorkspaceDiagnosticParams diagnosticsParams)
3733
=> diagnosticsParams.Identifier;
3834

0 commit comments

Comments
 (0)