Add structured import and reference extraction - #28
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces new public APIs to extract structured imports and filtered member references from source files across multiple languages, building on the existing Tree-sitter parsing infrastructure in outline.
Changes:
- Adds exported data models (
ImportKind,Import,Ref) plus newImportsandRefsextraction APIs. - Implements per-language import extraction (Python/JS/TS plus Hyrum-targeted ecosystems like Go/Ruby/Rust/PHP/Elixir) and receiver-filtered reference extraction.
- Refactors parsing into a shared
parseSourcehelper and adds tests/benchmarks + README documentation.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| syntax.go | Adds exported ImportKind, Name, Import, and Ref types forming the new public API surface. |
| node.go | Introduces shared Tree-sitter node helpers used by both import and reference extraction. |
| import.go | Implements Imports and core Python/JS/TS import extraction. |
| import_hyrum.go | Adds additional import extraction implementations (Go/Ruby/Rust/PHP/Elixir) aligned with Hyrum use cases. |
| import_test.go | Adds unit tests covering multiple languages and edge cases (e.g., multiline Python imports, CommonJS). |
| ref.go | Implements Refs and shared member-access traversal for multiple languages. |
| ref_hyrum.go | Adds Ruby/PHP-specific reference extraction helpers. |
| ref_test.go | Adds unit tests validating receiver-filtered member extraction across languages. |
| syntax_bench_test.go | Adds benchmarks for Imports (Python/JS) and Refs (JS). |
| outline.go | Refactors parsing into reusable parseSource helper used by Outline/Imports/Refs. |
| README.md | Documents the new APIs and provides an example snippet. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Adds structured
ImportsandRefsAPIs for extracting consumed modules, local aliases, and filtered member references.Covers Python, JavaScript and TypeScript, Go, Ruby, Rust, PHP, and Elixir, including multiline Python imports and CommonJS forms used by Hyrum.
Closes #27.