Skip to content

Add LSP TypeHierarchy Support#83011

Merged
JoeRobich merged 1 commit intomainfrom
dev/jorobich/lsp-typehierarchy
Apr 7, 2026
Merged

Add LSP TypeHierarchy Support#83011
JoeRobich merged 1 commit intomainfrom
dev/jorobich/lsp-typehierarchy

Conversation

@JoeRobich
Copy link
Copy Markdown
Member

@JoeRobich JoeRobich commented Apr 1, 2026

Implements the following LSP APIs:

  • textDocument/prepareTypeHierarchy
  • typeHierarchy/supertypes
  • typeHierarchy/subtypes

Builds on #83001

Resolves #83008

Recording.2026-03-31.235757.mp4
Microsoft Reviewers: Open in CodeFlow

@JoeRobich JoeRobich requested a review from a team as a code owner April 1, 2026 06:59
@JoeRobich JoeRobich force-pushed the dev/jorobich/lsp-typehierarchy branch from 786c0c6 to f013072 Compare April 2, 2026 14:26
var solution = document.Project.Solution;
var typeSymbol = await TypeHierarchyHelpers.GetTypeSymbolAsync(request.Item, solution, cancellationToken).ConfigureAwait(false);
if (typeSymbol == null)
return null;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Presumably this can fail if the workspace is edited so that the symbol no longer exists. Is the client smart enough to re-request information in this case, or should we throw LspErrorCodes.ContentModified (and is the client smart enough to handle that)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

According to the LSP spec, Will return null if the server couldn’t infer a valid type from item in the params..

var document = context.GetRequiredDocument();
var solution = document.Project.Solution;
var typeSymbol = await TypeHierarchyHelpers.GetTypeSymbolAsync(request.Item, solution, cancellationToken).ConfigureAwait(false);
if (typeSymbol == null)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

similar q as above

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Same as above

@JoeRobich JoeRobich merged commit 26fdc36 into main Apr 7, 2026
25 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable Type Hierarchy calls in Roslyn LSP

2 participants