Skip to content

Share document symbol endpoint with VS Code #11769

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

Merged

Conversation

davidwengier
Copy link
Member

@davidwengier davidwengier commented Apr 24, 2025

Also fixes a serialization problem that broke this in VS, when we went to Roslyn LSP types. This one is extra cool because it's still a very low effort port to VS Code, but we previously didn't support document symbols in VS Code at all. Chasing parity while also leapfrogging? 😁

image

Part of #11759

@davidwengier davidwengier requested a review from a team as a code owner April 24, 2025 00:58
var codeDocument = await context.GetCodeDocumentAsync(cancellationToken).ConfigureAwait(false);
var csharpDocument = codeDocument.GetCSharpDocument();

return _documentSymbolService.GetDocumentSymbols(context.Uri, csharpDocument, csharpSymbols);
}

[return: NotNullIfNotNull(nameof(roslynDocumentSymbols))]
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think DocumentSymbol[]? is right for the signature. TryGetFirst on SumType<DocumentSymbol[], SymbolInformation[]> should guarantee a non-null value I think

Copy link
Member Author

Choose a reason for hiding this comment

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

Thats true, but this method is called recursively for the Children property, which is nullable. I guess I can handle the null for that inline though. Seems a bit nicer :)

…VSCodeDocSymbol

# Conflicts:
#	src/Razor/src/Microsoft.CodeAnalysis.Razor.CohostingShared/Microsoft.CodeAnalysis.Razor.CohostingShared.projitems
@davidwengier davidwengier enabled auto-merge April 24, 2025 06:51
@davidwengier davidwengier merged commit 52b9a85 into dotnet:main Apr 24, 2025
11 checks passed
@davidwengier davidwengier deleted the dev/dawengie/CohostVSCodeDocSymbol branch April 24, 2025 07:26
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Apr 24, 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
Development

Successfully merging this pull request may close these issues.

2 participants