Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port semantic tokens range endpoint to cohost server #9761

Merged
merged 12 commits into from
Dec 27, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,19 @@ public static void AddHoverServices(this IServiceCollection services)
services.AddSingleton<IHoverInfoService, HoverInfoService>();
}

public static void AddSemanticTokensServices(this IServiceCollection services)
public static void AddSemanticTokensServices(this IServiceCollection services, LanguageServerFeatureOptions featureOptions)
{
services.AddHandlerWithCapabilities<SemanticTokensRangeEndpoint>();
if (!featureOptions.UseRazorCohostServer)
{
services.AddHandlerWithCapabilities<SemanticTokensRangeEndpoint>();
// Ensure that we don't add the default service if something else has added one.
services.TryAddSingleton<IRazorSemanticTokensInfoService, RazorSemanticTokensInfoService>();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that there is no else case for this if (!featureOptions.UseRazorCohostServer) condition,

I wonder where is the cohost setup happening and why we don't add IRazorSemanticTokensInfoService for when UseRazorCohostServer is set to true.

Copy link
Contributor Author

@davidwengier davidwengier Jan 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cohosting uses MEF for DI, so the setup is all done via attributes and not by manually adding things to service collections


services.AddHandler<RazorSemanticTokensRefreshEndpoint>();

services.AddSingleton<WorkspaceSemanticTokensRefreshPublisher, DefaultWorkspaceSemanticTokensRefreshPublisher>();
services.AddSingleton<IProjectSnapshotChangeTrigger, DefaultWorkspaceSemanticTokensRefreshTrigger>();

// Ensure that we don't add the default service if something else has added one.
services.TryAddSingleton<IRazorSemanticTokensInfoService, RazorSemanticTokensInfoService>();
}

public static void AddCodeActionsServices(this IServiceCollection services)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ protected override ILspServices ConstructLspServices()
services.AddLifeCycleServices(this, _clientConnection, _lspServerActivationTracker);

services.AddDiagnosticServices();
services.AddSemanticTokensServices();
services.AddSemanticTokensServices(featureOptions);
services.AddDocumentManagementServices(featureOptions);
services.AddCompletionServices(featureOptions);
services.AddFormattingServices();
Expand Down