Skip to content

Navigate to a Razor file when GTD/FAR/GTI is run in C# on the class name#12580

Merged
davidwengier merged 16 commits intomainfrom
dev/dawengie/GoToDefComponent
Dec 11, 2025
Merged

Navigate to a Razor file when GTD/FAR/GTI is run in C# on the class name#12580
davidwengier merged 16 commits intomainfrom
dev/dawengie/GoToDefComponent

Conversation

@davidwengier
Copy link
Member

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.

@davidwengier davidwengier requested a review from a team as a code owner December 10, 2025 02:48
@davidwengier davidwengier changed the title Navigate to a Razor file when GTD is run in C# on the class name Navigate to a Razor file when GTD/FAR/GTI is run in C# on the class name Dec 10, 2025
var codeDocument = await documentSnapshot.GetGeneratedOutputAsync(cancellationToken).ConfigureAwait(false);

var mappedSpans = MapSpans(codeDocument, [span]);
var mappedSpans = MapSpans(codeDocument, [span], csharpSyntaxNode);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this all just MapSpansAsync?

Copy link
Member Author

@davidwengier davidwengier Dec 10, 2025

Choose a reason for hiding this comment

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

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved some more code in to MapSpans. Let me know if I've misunderstood your comment

The old language server tests don't use the source generator, so the assert breaks them.
Copy link
Contributor

@ToddGrun ToddGrun left a comment

Choose a reason for hiding this comment

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

:shipit:

@davidwengier davidwengier merged commit 0dc7af6 into main Dec 11, 2025
10 checks passed
@davidwengier davidwengier deleted the dev/dawengie/GoToDefComponent branch December 11, 2025 22:10
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants