feat(gea-tools): add go-to-definition and auto-import for JSX components#15
Conversation
|
Caution Review failedFailed to post review comments 📝 WalkthroughWalkthroughThe pull request introduces two new language-server capabilities: "Go to Definition" for JSX components and "Quick Fix Auto Import" for inserting missing imports of default-exported components. Supporting infrastructure refactors component discovery to scan the workspace, deduplicate components, and select the best match by path proximity. Changes
Sequence Diagram(s)sequenceDiagram
participant Editor as Editor / Client
participant Server as Language Server
participant Discovery as Component Discovery
participant FileSystem as File System
rect rgba(0, 150, 0, 0.5)
Note over Editor,FileSystem: Go to Definition Flow
Editor->>Server: onDefinition(cursor position)
Server->>Server: Parse JSX tag context
Server->>Discovery: getBestComponentMatch(tagName)
Discovery->>Discovery: Filter default exports & rank by path distance
Discovery-->>Server: Component with filePath & declarationOffset
alt Same File
Server->>Editor: Location(current file, declaration line)
else Different File
Server->>FileSystem: Read target file
FileSystem-->>Server: File contents
Server->>Server: Map declarationOffset to Position
Server->>Editor: Location(target file, declaration line)
end
end
rect rgba(0, 0, 150, 0.5)
Note over Editor,FileSystem: Quick Fix Auto Import Flow
Editor->>Server: onCodeAction(unknown component diagnostic)
Server->>Server: Parse component name from diagnostic
Server->>Discovery: getBestComponentMatch(component name)
Discovery-->>Server: Best matching component
Server->>Server: Check if import already exists
alt No Import Found
Server->>Server: Compute relative import path
Server->>Server: Find import block insertion point
Server->>Editor: CodeAction with WorkspaceEdit (insert import)
else Import Exists
Server->>Editor: (No action offered)
end
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Doesn't jump to definition work right now in VS Code / Cursor? |
|
The main benefit is consistency.
|
What this does
This improves the JSX editing experience in
gea-tools.It adds Go to Definition for JSX component tags and a Quick Fix for missing imports when a default-exported component is used before being imported.
To support that, the component discovery logic now scans the workspace and keeps enough metadata to resolve declarations and generate relative import paths.
Why
gea-toolsalready provides completions and hover information, but two common editing actions were still missing:This makes the extension more useful during regular development and reduces friction when working across multiple components.
Notes
Validation
npm run compileinpackages/gea-toolspackages/gea-tools/README.mdpackages/gea-tools/TESTING.mdSummary by CodeRabbit
New Features
Documentation