Skip to content

Add structured import and reference extraction - #28

Merged
andrew merged 2 commits into
mainfrom
imports-refs
Aug 11, 2026
Merged

Add structured import and reference extraction#28
andrew merged 2 commits into
mainfrom
imports-refs

Conversation

@andrew

@andrew andrew commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Adds structured Imports and Refs APIs 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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 new Imports and Refs extraction 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 parseSource helper 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.

Comment thread import.go
Comment thread ref.go
Comment thread syntax.go
Comment thread README.md Outdated
@andrew
andrew merged commit c90ebc3 into main Aug 11, 2026
7 checks passed
@andrew
andrew deleted the imports-refs branch August 11, 2026 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Imports() and Refs() for structured import/member-access extraction

2 participants