[Sonic] Support multiple C# documents in hover - #84031
Merged
Merged
Conversation
May as well do this in the feature branch, since doing it in main would be conflict city
This is going to be generally useful in future
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Razor cohosting hover plumbing to correctly handle Razor positions that map into either the implementation or declaration generated C# document, and aligns the related hover helpers/types under the Remote Razor layer with updated unit coverage.
Changes:
- Thread an
InDeclDocumentflag through Razor→C# position mapping so callers can choose the correct generated C# document. - Update
RemoteHoverServiceto request C# hover from the appropriate generated document and map hover ranges back using the matching C# document. - Move/rename hover helpers into
Microsoft.CodeAnalysis.Remote.Razor.Hoverand expand cohosting hover tests to cover impl/decl/legacy scenarios.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Razor/src/Razor/test/Microsoft.CodeAnalysis.Remote.Razor.UnitTests/Hover/HoverFactoryTest.cs | Updates test namespace/imports to match the moved Remote hover types. |
| src/Razor/src/Razor/test/Microsoft.CodeAnalysis.Razor.CohostingShared.UnitTests/ProjectAvailabilityTests.cs | Updates ComponentAvailabilityService namespace usage after the move. |
| src/Razor/src/Razor/test/Microsoft.CodeAnalysis.Razor.CohostingShared.UnitTests/Endpoints/CohostHoverEndpointTest.cs | Renames/extends hover tests to validate impl/decl/legacy C# hover behavior. |
| src/Razor/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/RazorDocumentServiceBase.cs | Uses the new Razor→C# mapping helper to capture InDeclDocument when preferring C# over HTML. |
| src/Razor/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Hover/RemoteHoverService.cs | Uses InDeclDocument to pick the correct generated C# document and to map ranges back correctly. |
| src/Razor/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Hover/HoverFactory.cs | Moves hover factory into the Remote hover namespace (no functional changes observed here). |
| src/Razor/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Hover/HoverDisplayOptions.cs | Moves hover display options into the Remote hover namespace. |
| src/Razor/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Hover/ComponentAvailabilityService.cs | Moves ComponentAvailabilityService into the Remote hover namespace. |
| src/Razor/src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/Completion/RemoteCompletionService.cs | Updates import for ComponentAvailabilityService after its namespace move. |
| src/Razor/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/DocumentMapping/IDocumentMappingServiceExtensions.cs | Adds a convenience mapping helper that checks both impl/decl C# documents and returns inDeclDocument. |
| src/Razor/src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Completion/Delegation/DelegatedCompletionHelper.cs | Propagates InDeclDocument when synthesizing provisional completion position info. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I decided to continue the work to move code from Workspaces up to Remote in this branch, rather than just generate conflicts in main, so this has a little more in it, but the diffs are just namespace changes. Also has one commit from the document highlight change in here, so you might have seen it before.
The changes to RemoteHoverService really highlight how useful the
InDeclDocumentbool can be.Microsoft Reviewers: Open in CodeFlow