Navigate to a Razor file when GTD/FAR/GTI is run in C# on the class name#12580
Merged
davidwengier merged 16 commits intomainfrom Dec 11, 2025
Merged
Navigate to a Razor file when GTD/FAR/GTI is run in C# on the class name#12580davidwengier merged 16 commits intomainfrom
davidwengier merged 16 commits intomainfrom
Conversation
ToddGrun
reviewed
Dec 10, 2025
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/CSharpSyntaxNodeExtensions.cs
Show resolved
Hide resolved
ToddGrun
reviewed
Dec 10, 2025
src/Razor/src/Microsoft.CodeAnalysis.Razor.Workspaces/Extensions/CSharpSyntaxNodeExtensions.cs
Show resolved
Hide resolved
ToddGrun
reviewed
Dec 10, 2025
...azor/src/Microsoft.CodeAnalysis.Remote.Razor/DocumentMapping/RemoteDocumentMappingService.cs
Outdated
Show resolved
Hide resolved
ToddGrun
reviewed
Dec 10, 2025
| var codeDocument = await documentSnapshot.GetGeneratedOutputAsync(cancellationToken).ConfigureAwait(false); | ||
|
|
||
| var mappedSpans = MapSpans(codeDocument, [span]); | ||
| var mappedSpans = MapSpans(codeDocument, [span], csharpSyntaxNode); |
Contributor
There was a problem hiding this comment.
Is this all just MapSpansAsync?
Member
Author
There was a problem hiding this comment.
Do you mean just call MapSpansAsync here instead of getting the razor document and calling MapSpans? That could work, but code below this needs the document and code document etc. so there would still be doubling up.
Having said that, I could move the tree retrieval into MapSpans and make it async, and share a bit more code.
Member
Author
There was a problem hiding this comment.
Moved some more code in to MapSpans. Let me know if I've misunderstood your comment
ToddGrun
reviewed
Dec 10, 2025
src/Razor/src/Microsoft.CodeAnalysis.Remote.Razor/DocumentMapping/RemoteSpanMappingService.cs
Outdated
Show resolved
Hide resolved
ToddGrun
reviewed
Dec 10, 2025
...or/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Cohost/CohostRoslynGoToDefTest.cs
Outdated
Show resolved
Hide resolved
ToddGrun
reviewed
Dec 10, 2025
src/Razor/test/Microsoft.VisualStudio.Razor.IntegrationTests/InProcess/EditorInProcess_Text.cs
Outdated
Show resolved
Hide resolved
The old language server tests don't use the source generator, so the assert breaks them.
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.
Fixes #7213
Fixes #11440
Fixes #6403
When span mapping tries to map to a components' generated class declaration, we instead map to (0, 0) in the corresponding .razor file. I did this in the RemoteSpanMapping service so that it only effects FAR, GTD and GTI (ie, high level features) and not more generic span mapping operations, like in formatting or rename etc.