[Repo Assist] feat: implement textDocument/prepareTypeHierarchy, typeHierarchy/supertypes, typeHierarchy/subtypes#1508
Draft
github-actions[bot] wants to merge 2 commits intomainfrom
Conversation
…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>
13 tasks
Member
|
/repo-assist add tests for the PR |
Contributor
Author
|
❌ Repo Assist failed. Please review the logs for details. |
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.
🤖 This is an automated pull request from Repo Assist.
Closes #1097.
What
Implements the three Type Hierarchy LSP endpoints that were previously logged as
logUnimplementedRequeststubs:textDocument/prepareTypeHierarchytypeHierarchy/supertypestypeHierarchy/subtypesAlso advertises
TypeHierarchyProvider = trueinServerCapabilitiesso editors know the feature is available.How
TextDocumentPrepareTypeHierarchyResolves the symbol at the cursor position. If it is a
FSharpEntity(class, interface, union, record, enum, module) or anFSharpMemberOrFunctionOrValueconstructor (which redirects to its declaring entity), returns aTypeHierarchyItempointing to the declaration range of that type.TypeHierarchySupertypesRe-resolves the entity from the item's
Uri/SelectionRangeby re-type-checking the source file, then returnsTypeHierarchyItems for:BaseType(if present and notSystem.Object)entity.DeclaredInterfacesTypeHierarchySubtypesUses
GetUsesOfSymbolacross the whole project (same approach asTextDocumentImplementation) 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.TypeHierarchyHelpersmoduleA new module (mirrors the existing
CallHierarchyHelpers) that provides:getEntitySymbolKind— mapsFSharpEntityproperties toSymbolKindentityToTypeHierarchyItem— converts anFSharpEntityto aTypeHierarchyItemgetDirectSupertypes— returns the direct supertypes of an entityTrade-offs
typeHierarchy/supertypesagain on each returned item.PrepareTypeHierarchyworks for any type, including those from NuGet packages, but the returned Uri will be a syntheticfsharp://…URI for non-local files. Supertypes/subtypes of external types will fail gracefully withNone.Test Status
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).