Skip to content

Pass in HostServices when creating the LSP server#65384

Merged
dibarbet merged 1 commit intodotnet:mainfrom
dibarbet:fix_misc_registration
Nov 18, 2022
Merged

Pass in HostServices when creating the LSP server#65384
dibarbet merged 1 commit intodotnet:mainfrom
dibarbet:fix_misc_registration

Conversation

@dibarbet
Copy link
Member

@dibarbet dibarbet commented Nov 12, 2022

to ensure that the lsp misc workspace it creates can use items from the host mef composition.

This fixes a bug where the LspMiscellaneousFIlesWorkspace was not registered because the LspWorkspaceRegistrationEventListener was not part of the default mef services.

Resolves #57243 as a side effect - no need to make it nullable when we reuse the correct host services from vs

Thanks @jasonmalinowski for the idea.

PR validation in progress to verify does not regress RPS

…misc workspace it creates can use items from the host mef composition
@dibarbet dibarbet requested a review from a team as a code owner November 12, 2022 00:31
@ghost ghost added the Area-IDE label Nov 12, 2022
WellKnownLspServerKinds serverKind,
ILspServiceLogger logger);
ILspServiceLogger logger,
HostServices hostServices);
Copy link
Member Author

Choose a reason for hiding this comment

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

to avoid having MS.CA.LanguageServer.Protocol depend on vs-mef, we use HostServices instead of ExportProvider. Then we import the ExportProvider at the layers that are already using it (e.g. EditorFeatures)

var locations = await GetAnnotatedLocationsAsync(testWorkspace, testWorkspace.CurrentSolution);
var server = new TestLspServer(testWorkspace, locations, initializationOptions.ClientCapabilities, initializationOptions.ServerKind, logger);

var (clientStream, serverStream) = FullDuplexStream.CreatePair();
Copy link
Member Author

Choose a reason for hiding this comment

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

just moved to unify the ctors

internal interface IRazorLanguageServerFactoryWrapper
{
IRazorLanguageServerTarget CreateLanguageServer(JsonRpc jsonRpc, IRazorCapabilitiesProvider capabilitiesProvider);
IRazorLanguageServerTarget CreateLanguageServer(JsonRpc jsonRpc, IRazorCapabilitiesProvider capabilitiesProvider, HostServices hostServices);
Copy link
Member

Choose a reason for hiding this comment

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

Do we need a compat version of this since it's ExternalAPIs or is this not being called yet?

Copy link
Member Author

Choose a reason for hiding this comment

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

I confirmed with @allisonchou that this is only being called in unit tests,. so only when Razor updates to a new version of Roslyn will they need to update this.

ExceptionStrategy = ExceptionProcessing.ISerializable,
};

// Workspace listener events do not run in tests, so we manually register the lsp misc workspace.
Copy link
Member

Choose a reason for hiding this comment

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

Is that intentional? Is that something we can change?

Copy link
Member Author

Choose a reason for hiding this comment

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

IIRC it is intentional, I think to prevent other things (like sln crawler) from automatically spinning up in tests. cc @tmat

@dibarbet
Copy link
Member Author

@dibarbet dibarbet merged commit b32d1df into dotnet:main Nov 18, 2022
@dibarbet dibarbet deleted the fix_misc_registration branch November 18, 2022 00:52
@ghost ghost added this to the Next milestone Nov 18, 2022
@allisonchou allisonchou modified the milestones: Next, 17.5 P2 Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[LSP] Always create lsp misc files and resolve rps regression

4 participants