-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Symbol-Level Drill-Down & Call Hierarchy (LSP-Based) #45
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
Open
magic5644
wants to merge
20
commits into
main
Choose a base branch
from
001-lsp-call-hierarchy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
- Added SymbolNode component to represent symbols in the graph. - Updated ReactFlowGraph to support switching between file and symbol views. - Introduced layout options (hierarchical, force, radial) for better visualization. - Enhanced buildGraph function to handle symbol data and relationships. - Implemented radial and force-directed layouts for improved graph representation. - Updated SymbolCardView to include a button for switching to graph view. - Added utility functions for symbol categorization and styling. - Enhanced tests to cover new symbol graph features and ensure proper functionality.
…ompt file recommendations
…rarchy and symbol drill-down feature
- Add TypeScript types: SymbolNode, CallEdge, IntraFileGraph, BreadcrumbPath - Add message protocol: SymbolGraphMessage, SymbolAnalysisProgressMessage, SymbolEmptyStateMessage, NavigateToSymbolMessage - Create LspCallHierarchyAnalyzer with cycle detection and path normalization - Create test fixtures: simple-calls, recursive-call, class-methods, anonymous-functions - Pass 8 unit tests for analyzer (filtering, cycles, cross-platform paths) - Update implementation readiness checklist (43/43 complete) - Update requirements checklist (16/16 complete) Phase 1: Setup ✅ (T001-T003) Phase 2: Foundational ✅ (T004-T008) Next: Phase 3 User Story 1 MVP (T009-T029)
Verified existing implementation: - SymbolViewService with LSP integration ✅ - LspCallHierarchyService with call hierarchy APIs ✅ - SymbolNode.tsx component ✅ - GraphProvider integration with drillDown ✅ - E2E tests passing (90 tests including Symbol-Level Analysis) ✅ Phase 3: US1 Complete (T009-T029) - TypeScript symbol navigation working
- Python integration: 26 tests passing (Pylance LSP) - Rust integration: 31 tests passing (rust-analyzer LSP) - Graceful degradation for unsupported file types ✅ - Empty state messaging ✅ Phases 1-4 Complete: 42/100 tasks - Phase 1: Setup (T001-T003) ✅ - Phase 2: Foundational (T004-T008) ✅ - Phase 3: US1 MVP TypeScript (T009-T029) ✅ - Phase 4: US2 Multi-Language (T030-T042) ✅ Next: Phase 5-8 (Visual enhancements, MCP, live updates, polish)
Use lowercase with underscores (graphitlive_*) convention matching existing MCP tools in codebase
Package validation: - ✅ Zero .map files in .vsix (16.78 MB) - ✅ 1009 unit tests passing - ✅ 90 E2E tests passing 44/100 tasks complete. Constitution compliance verified.
- Create BreadcrumbNav.tsx with Project > Folder > filename.ts display - Integrate breadcrumb into App.tsx for symbol mode - Implement click handler to return to file view (FR-006, SC-008) - Support cross-platform paths (Windows/Unix) - Update vitest config to include .tsx test files - Remove unit test (project uses E2E tests for React components) Tasks complete: 48/100 (T049-T052)
- Run Snyk code scan on LspCallHierarchyAnalyzer: 0 issues - Run Snyk code scan on BreadcrumbNav: 0 issues - Run SonarQube analysis on both files - Fix SonarQube issues in BreadcrumbNav: - Use <nav> instead of <div> with role="navigation" - Use segment.label as React key instead of array index - All 91 unit tests passing Tasks complete: 50/100 (T097-T098) Constitution Principle IV (Package Integrity) VERIFIED
…T043-T048) - Update symbol colors to match FR-010 specification: - Classes: Deep purple (#9966CC) - was cyan - Functions: Vibrant blue (#4A9EFF) - was teal - Variables: Amber (#FFA500) - was light blue - Methods/Constructors match their parent categories - Add cycle badge to edges: '🔄 cycle' with error foreground color - Existing edge differentiation verified: - Solid arrows for function calls (strokeWidth: 2) - Dashed arrows for references (strokeDasharray: '4 4') - Labels show 'references' vs implicit 'calls' - Fix integration test to match new cycle label format All 91 unit tests passing Tasks complete: 56/100 (T043-T048)
README.md updates: - Add comprehensive Symbol-Level Drill-Down section - Explain LSP-powered analysis for TS/JS/Python/Rust - Document color coding: purple classes, blue functions, amber variables - Show edge differentiation: solid calls, dashed references, cycle badges - Include breadcrumb navigation usage - List benefits: code flow understanding, impact analysis, refactoring CHANGELOG.md updates: - Add v1.7.0 (Unreleased) section - Document new symbol drill-down feature - List multi-language support and visual enhancements - Include security/quality/testing metrics Tasks complete: 58/100 (T095-T096)
- Reorganized import statements for better clarity. - Standardized string quotes to double quotes for consistency. - Improved test descriptions for better understanding. - Enhanced edge and node assertions to ensure clarity in test outcomes. - Added new tests for edge styling based on relation types (call vs reference). - Implemented cycle detection tests to validate circular dependencies. - Updated tsconfig.json to include ".vscode-test" directory for TypeScript compilation.
- Added debounce logic to handle file save events in GraphProvider, ensuring efficient updates to the graph after rapid edits. - Introduced a refreshing message to indicate loading state during graph updates. - Enhanced SymbolViewService to build intra-file graphs with cycle detection and added cycle type classification. - Updated shared types to include new message types and cycle detection structures. - Improved ReactFlowGraph component to visually indicate loading states and highlight changes in the graph. - Added unit tests for debounce logic and integration tests for live updates, ensuring correct behavior during rapid file edits. - Created benchmark tests for symbol graph rendering performance under various conditions.
- Added @dagrejs/dagre as a dependency and updated hono to version 4.11.5. - Updated @types/node to version 25.0.10 and mocha to version 11.3.0. - Enhanced ReactFlowGraph to track mode changes and improve incremental change detection for graph updates. - Modified buildGraph to infer external symbol categories based on naming conventions. - Updated layout and nodeUtils to use the new dagre package. - Added test fixtures for various symbol types, including classes, functions, and recursion. - Implemented E2E tests for symbol-level analysis, including color coding, edge differentiation, and contextual naming for anonymous functions.
- Added `isExternal` property to `SymbolNodeData` interface to handle external symbols. - Updated rendering logic in `SymbolNode` to apply dimming and dashed borders for external references. - Enhanced tooltip to indicate external status. - Refactored node styling in `getNodeStyle` to utilize shared color constants for file types. refactor: Improve language detection and performance benchmarks - Replaced inline language detection logic with `detectLanguageFromExtension` utility in Python and Rust performance benchmarks. - Updated tests to ensure accurate language detection for various file extensions. test: Add integration tests for analyze_file_logic MCP tool - Implemented comprehensive integration tests for the `analyze_file_logic` MCP tool covering TypeScript and Python files. - Validated error handling for unsupported file types and non-existent files. - Ensured proper handling of LSP timeouts and partial results. test: Create unit tests for language detection utilities - Added unit tests for `detectLanguageFromExtension`, `isLanguage`, and `getExtensionsForLanguage` functions. - Verified mappings for supported languages and extensions.
…guages - Refactored LspCallHierarchyAnalyzer to improve contextual naming for anonymous functions, including specific checks for array methods, event handlers, promise chains, and timers. - Updated PathResolver to support Python-specific imports and improved handling of module resolution, including relative paths and special module patterns. - Added utility functions for Python file detection and relative import resolution. - Enhanced EditorNavigationService with improved logging and error handling for module resolution. - Updated constants to categorize file extensions by language for better type safety. - Improved language detection logic to handle Windows paths correctly. - Refactored tests to align with new functionality and ensure coverage for recent changes.
… symbol reverse index handling
…pWorker for improved performance and symbol handling
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.
Symbol-Level Drill-Down & Call Hierarchy (LSP-Based)
🎯 Summary
This PR introduces symbol-level dependency visualization within files, enabling developers to explore function-to-function and class-to-class relationships. The feature leverages VS Code's Language Server Protocol (LSP) for multi-language support and accurate call hierarchy detection.
Branch:
001-lsp-call-hierarchy→mainFeature Status: MVP Complete (87% of total scope)
📊 What's Included
✅ Core Features Implemented (100% MVP)
1. LSP-Based Symbol Analysis
executeDocumentSymbolProvider,executePrepareCallHierarchy,executeOutgoingCallsProvider)2. Interactive Symbol Graph Visualization
#9966CC)#4A9EFF)#FFA500)Project > folder > filename.tswith "Back to Project" button3. User Interaction Flow
4. MCP Tool Integration (for AI/LLM)
graphitlive_analyze_file_logic🏗️ Architecture Changes
New Components
Analyzer Layer
LspCallHierarchyAnalyzer.ts: LSP API wrapper with cycle detection (DFS traversal)buildIntraFileGraph(): Main entry point for symbol analysisdetectCycles(): Marks all nodes in recursion stack when back-edge detectedgenerateSymbolId(): Creates scoped IDs (ClassName.methodName) to prevent collisionsExtension Services
SymbolViewService.ts: Orchestrates symbol view lifecycleLspCallHierarchyAnalyzerto generateIntraFileGraphsymbolGraphmessages to webviewnavigateToSymbolfor click-to-code navigationWebview Components
SymbolGraphView.tsx: React component for symbol visualizationBreadcrumbNav.tsx: Navigation component for hierarchical navigationMCP Integration
McpWorker.ts: AddedexecuteAnalyzeFileLogic()functionresponse_formatparameterType System Extensions
Added to
src/shared/types.ts:SymbolNode: Represents function/class/variable with metadataCallEdge: Represents call or reference relationshipIntraFileGraph: Complete symbol graph structureExtensionToWebview: New message types (symbolGraph,symbolError,navigateToSymbol)🐛 Bug Fixes (Code Audit Results)
High Priority
Fixed Spider→LSP ID conversion (line 1858 in
McpWorker.ts)filePath:filePath:symbolName)symbolNamewithsplit(':').pop()before passing to LSPFixed reverse index initialization (line 1393 in
McpWorker.ts)findReferencingFiles(rootDir)instead of per-file iterationMedium Priority
Fixed cycle detector false positives (line 202 in
LspCallHierarchyAnalyzer.ts)recursionStackand mark all nodes when back-edge detectedAdded reverse index cache invalidation (lines 437,447 in
McpWorker.ts)symbolReverseIndex.removeDependenciesFromSource()inperformFileInvalidation()Low Priority (Performance Optimizations)
Parallelized edge filtering (line 715 in
McpWorker.ts)awaitloop for edge verification (O(n) performance)Promise.all()for parallel verification (~10x speedup)Enhanced
generateSymbolIdwith scope (line 288 inLspCallHierarchyAnalyzer.ts)containerNameparameter (Class.method)🧪 Testing & Quality
Test Coverage
showGraph,refreshGraph,expandAllNodes, etc.)Quality Validation
.mapfiles in production bundle (16.71 MB)Cross-Platform Testing
normalizePath()utility📈 Performance Metrics
🔄 Migration Path
For Users
For Developers
src/shared/types.tswith Zod validation📋 Known Limitations (Future Work)
Not Included in This PR (Planned for v2.0)
Technical Debt
🚀 Deployment Checklist
Pre-Merge Validation ✅
npm test)npm run check:types)npm run lint:fix)npm run package:verify)npm run test:vscode:vsix)Post-Merge Steps
package.jsonto1.7.0CHANGELOG.mdexcerptnpm run publish)📚 Documentation Updates
Updated Files
AGENTS.md: Added LspCallHierarchyAnalyzer to architecture docs.github/copilot-instructions.md: Comprehensive LSP Call Hierarchy sectionchangelog.md: Detailed feature description with screenshotsREADME.md: Usage instructions for symbol drill-downFEATURE_STATUS.md: Complete progress tracking (NEW)VERIFICATION_DETAILLEE.md: Detailed spec-to-code mapping (NEW)Developer Resources
specs/001-lsp-call-hierarchy/spec.mdspecs/001-lsp-call-hierarchy/tasks.mdspecs/001-lsp-call-hierarchy/research.mdspecs/001-lsp-call-hierarchy/contracts/💬 Review Notes
Key Areas to Focus On
LSP Integration:
src/analyzer/LspCallHierarchyAnalyzer.ts(lines 1-350)Service Orchestration:
src/extension/services/SymbolViewService.ts(lines 1-400)React Component:
src/webview/components/SymbolGraphView.tsx(lines 1-300)MCP Tool:
src/mcp/McpWorker.ts(lines 1760-1900)Breaking Change Analysis
🙏 Acknowledgments
Ready to Merge: ✅ All quality gates passed, MVP complete, documentation updated.