Add symbol metadata to outlined files - #24
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds symbol metadata capture to the outlining pipeline so each outlined File can expose an ordered list of top-level Symbol declarations (name, kind, one-based line, export status) without re-parsing the source.
Changes:
- Introduces
Symbolextraction from existing tree-sitter query matches and attaches it to outlined results. - Extends language queries (
queries/*.scm) to capture top-level symbols across supported languages. - Plumbs symbols through
Packoutput and adds comprehensive multi-language tests.
Reviewed changes
Copilot reviewed 40 out of 40 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| outline.go | Adds an internal outlining entrypoint that optionally collects symbols while outlining. |
| pack.go | Extends File to include Symbols and populates them when outlining is enabled. |
| pack_test.go | Verifies symbols are present when compress/outlining is enabled and absent when disabled. |
| symbol.go | Implements symbol extraction, export detection, ordering, and de-duplication logic. |
| symbol_test.go | Adds extensive tests validating symbol extraction across many languages. |
| queries/bash.scm | Adds captures for top-level Bash variables and functions. |
| queries/c.scm | Adds captures for top-level C preprocessor defs, types, vars, and functions. |
| queries/clojure.scm | Adds captures for Clojure top-level vars, funcs, and types. |
| queries/cmake.scm | Adds captures for CMake function/macro definitions. |
| queries/cpp.scm | Adds captures for C++ namespaces, types, vars, and functions. |
| queries/crystal.scm | Adds captures for Crystal types, consts, and methods. |
| queries/csharp.scm | Adds captures for C# types and method declarations (incl. local functions). |
| queries/d.scm | Adds captures for D types and functions. |
| queries/dart.scm | Adds captures for Dart types and functions. |
| queries/elixir.scm | Adds captures for Elixir modules/protocols/impls and function-like defs. |
| queries/erlang.scm | Adds captures for Erlang records/types and functions. |
| queries/fsharp.scm | Adds captures for F# modules/types and value bindings. |
| queries/go.scm | Adds captures for Go types, vars/consts, functions, and methods. |
| queries/groovy.scm | Adds captures for Groovy classes and functions. |
| queries/haskell.scm | Adds captures for Haskell types, binds, and functions. |
| queries/hcl.scm | Adds captures for Terraform/HCL blocks representing vars/types. |
| queries/java.scm | Adds captures for Java types and methods. |
| queries/javascript.scm | Adds captures for JS top-level classes, funcs, and arrow-func const/let bindings. |
| queries/julia.scm | Adds captures for Julia modules/types/consts and functions/macros. |
| queries/kotlin.scm | Adds captures for Kotlin classes/objects/types/properties/functions. |
| queries/lua.scm | Adds captures for Lua top-level functions and variable declarations. |
| queries/make.scm | Adds captures for Make variables and rules (as funcs). |
| queries/nim.scm | Adds captures for Nim types/const/var/let and procs/funcs/macros with export markers. |
| queries/ocaml.scm | Adds captures for OCaml modules/types/values/classes. |
| queries/perl.scm | Adds captures for Perl subroutine declarations. |
| queries/php.scm | Adds captures for PHP classes/types/functions/methods. |
| queries/python.scm | Adds captures for Python classes/functions and module-level assignments. |
| queries/r.scm | Adds captures for R function and variable assignments. |
| queries/ruby.scm | Adds captures for Ruby consts/classes/modules/methods. |
| queries/rust.scm | Adds captures for Rust modules/types/const/static/functions. |
| queries/scala.scm | Adds captures for Scala classes/traits/objects/enums/functions/vals/vars/types. |
| queries/starlark.scm | Adds captures for Starlark assignments and function definitions. |
| queries/swift.scm | Adds captures for Swift classes/protocols/typealiases/properties/functions. |
| queries/typescript.scm | Adds captures for TS declarations (interfaces/types/enums/classes/functions/const/let). |
| queries/zig.scm | Adds captures for Zig variable and function declarations. |
Suppressed comments (6)
symbol.go:329
for i := range root.NamedChildCount()does not compile becauseNamedChildCount()is a numeric count, not a slice/map. Use an indexed loop over[0, NamedChildCount()).
symbol.go:345for i := range node.NamedChildCount()does not compile (numeric count). Switch to an indexed loop to iterate named children.
symbol.go:381for i := range value.NamedChildCount()does not compile becauseNamedChildCount()is a numeric count. Iterate with an indexed loop.
symbol.go:397for i := range node.NamedChildCount()does not compile (numeric count). Use an indexed loop when scanning direct children.
symbol.go:413for i := range node.NamedChildCount()incollectNamesdoes not compile becauseNamedChildCount()is a numeric count. Use an indexed loop to recurse over children.
symbol.go:419for i := range root.NamedChildCount()does not compile (numeric count). Use an indexed loop when scanning top-level nodes for export statements.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+271
to
+275
| for i := range current.NamedChildCount() { | ||
| if visit(current.NamedChild(i)) { | ||
| return true | ||
| } | ||
| } |
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.
Add top-level declaration metadata to outlined files without parsing source a second time. Each outlined
Filenow includes orderedSymbolvalues with a name, kind, one-based line, and language-aware export status.Standard symbol captures cover every existing language query, including Go capitalization, JavaScript and TypeScript exports and CommonJS assignments, and Python underscore visibility.