Skip to content

[Repo Assist] feat: implement textDocument/prepareTypeHierarchy, typeHierarchy/supertypes, typeHierarchy/subtypes#1508

Draft
github-actions[bot] wants to merge 2 commits intomainfrom
repo-assist/feat-type-hierarchy-1097-69639b830d60d597
Draft

[Repo Assist] feat: implement textDocument/prepareTypeHierarchy, typeHierarchy/supertypes, typeHierarchy/subtypes#1508
github-actions[bot] wants to merge 2 commits intomainfrom
repo-assist/feat-type-hierarchy-1097-69639b830d60d597

Conversation

@github-actions
Copy link
Contributor

🤖 This is an automated pull request from Repo Assist.

Closes #1097.

What

Implements the three Type Hierarchy LSP endpoints that were previously logged as logUnimplementedRequest stubs:

Method Status
textDocument/prepareTypeHierarchy ✅ implemented
typeHierarchy/supertypes ✅ implemented
typeHierarchy/subtypes ✅ implemented

Also advertises TypeHierarchyProvider = true in ServerCapabilities so editors know the feature is available.

How

TextDocumentPrepareTypeHierarchy

Resolves the symbol at the cursor position. If it is a FSharpEntity (class, interface, union, record, enum, module) or an FSharpMemberOrFunctionOrValue constructor (which redirects to its declaring entity), returns a TypeHierarchyItem pointing to the declaration range of that type.

TypeHierarchySupertypes

Re-resolves the entity from the item's Uri/SelectionRange by re-type-checking the source file, then returns TypeHierarchyItems for:

  • the direct BaseType (if present and not System.Object)
  • each type in entity.DeclaredInterfaces

TypeHierarchySubtypes

Uses GetUsesOfSymbol across the whole project (same approach as TextDocumentImplementation) to find every place the target type appears in a type annotation (IsFromType = true, IsFromDefinition = false). For each such use, inspects all symbol uses in that file to find the enclosing entity definition whose declaration range contains the use range — those are direct subtypes.

TypeHierarchyHelpers module

A new module (mirrors the existing CallHierarchyHelpers) that provides:

  • getEntitySymbolKind — maps FSharpEntity properties to SymbolKind
  • entityToTypeHierarchyItem — converts an FSharpEntity to a TypeHierarchyItem
  • getDirectSupertypes — returns the direct supertypes of an entity

Trade-offs

  • Supertypes: Only direct supertypes are returned (as required by the LSP spec). The editor drives the recursive traversal by calling typeHierarchy/supertypes again on each returned item.
  • Subtypes: This is inherently a workspace-wide search (same performance profile as "Find All References"). External-assembly subtypes are not found (would require full reference assembly search).
  • External types: PrepareTypeHierarchy works for any type, including those from NuGet packages, but the returned Uri will be a synthetic fsharp://… URI for non-local files. Supertypes/subtypes of external types will fail gracefully with None.

Test Status

dotnet build src/FsAutoComplete/FsAutoComplete.fsproj -f net8.0  → Build succeeded (0 warnings, 0 errors)
dotnet fantomas src/FsAutoComplete/LspServers/AdaptiveFSharpLspServer.fs → 1 file formatted
dotnet build src/FsAutoComplete/FsAutoComplete.fsproj -f net8.0  → Build succeeded after formatting
dotnet build test/FsAutoComplete.Tests.Lsp/FsAutoComplete.Tests.Lsp.fsproj -f net8.0 → Build succeeded

No existing tests were broken. The feature is new functionality with no pre-existing tests; integration tests could be added in a follow-up (test infrastructure requires running a live FSAC server).

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@346204513ecfa08b81566450d7d599556807389f

…rtypes, typeHierarchy/subtypes (closes #1097)

Implements the three Type Hierarchy LSP endpoints that were previously stubs:

- TextDocumentPrepareTypeHierarchy: resolves the type entity at the given
  cursor position (FSharpEntity, or constructors → their declaring entity)
  and returns a TypeHierarchyItem.

- TypeHierarchySupertypes: re-resolves the entity from the item's Uri/
  SelectionRange, then returns TypeHierarchyItems for the direct base type
  (skipping System.Object) and all DeclaredInterfaces.

- TypeHierarchySubtypes: uses GetUsesOfSymbol across the whole project to
  find every place the target type appears in a type annotation (IsFromType),
  then for each such use locates the enclosing entity definition via
  GetAllUsesOfAllSymbolsInFile — those entities are the direct subtypes.

Also adds TypeHierarchyProvider = Some(U3.C1 true) to ServerCapabilities
so editors know the feature is available.

The new TypeHierarchyHelpers module mirrors the existing
CallHierarchyHelpers module in the same file.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Krzysztof-Cieslak
Copy link
Member

/repo-assist add tests for the PR

@github-actions
Copy link
Contributor Author

github-actions bot commented Mar 19, 2026

Repo Assist failed. Please review the logs for details.

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.

Implement Call Heirarchy and Type Heirarchy members

1 participant