Skip to content

Wire Call Hierarchy to editor (Shift+Alt+H) #235

@mitchdenny

Description

@mitchdenny

Summary

Wire the existing Call Hierarchy LSP infrastructure to the editor so users can explore incoming and outgoing function calls.

Trigger

  • Hotkey: Shift+Alt+H (VS Code default for "Show Call Hierarchy")
  • Alternative: Could use a command palette or context menu

Existing Infrastructure

Layer Location Method Status
LSP Client LanguageServerClient.cs RequestCallHierarchyPrepareAsync(), RequestCallHierarchyIncomingAsync(), RequestCallHierarchyOutgoingAsync() Exists
Feature Controller LspFeatureController.cs All three call hierarchy methods Exists
Decoration Provider LanguageServerDecorationProvider.cs All three call hierarchy methods Exists
Editor Primitive IEditorSession.cs ShowActionMenuAsync() for list display Exists
Editor Binding EditorNode.cs Not bound Missing

Implementation

1. Add Shift+Alt+H binding

bindings.Shift().Alt().Key(Hex1bKey.H).Action(TriggerCallHierarchyAsync, "Show call hierarchy");

2. Add TriggerCallHierarchyAsync method

  1. Call provider.RequestCallHierarchyPrepareAsync(line, column) to get the CallHierarchyItem at cursor
  2. If valid, show an ActionMenu with two choices: "Incoming Calls" and "Outgoing Calls"
  3. Based on selection:
    • Incoming: Call RequestCallHierarchyIncomingAsync(item) and display callers
    • Outgoing: Call RequestCallHierarchyOutgoingAsync(item) and display callees
  4. Display results in an ActionMenu or EditorOverlay listing each call with file/line info
  5. Selecting a result navigates to that location (similar to Go to Definition)

3. Navigation on selection

When user selects a call from the list:

  • If same file: move cursor to that position
  • If different file: could show the file path (cross-file navigation is a future feature)

4. Update README

  • Document Shift+Alt+H hotkey

Visual Behavior

  1. Cursor on addTask function, press Shift+Alt+H
  2. Menu appears: "Incoming Calls" / "Outgoing Calls"
  3. Select "Incoming Calls"
  4. Overlay shows: handleSubmit (line 42), processQueue (line 78)
  5. Select one to navigate there

Tests

  • Shift+Alt+H on function shows hierarchy menu
  • Incoming calls returns callers
  • Outgoing calls returns callees
  • Selecting a result navigates to the location
  • Invalid cursor position shows nothing

Notes

  • TypeScript language server supports call hierarchy
  • This is a multi-step interaction (prepare -> choose direction -> browse results)
  • Consider a tree view if the results are hierarchical (calls of calls)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions