Skip to content

Add symbol metadata to outlined files - #24

Merged
andrew merged 1 commit into
mainfrom
add-symbols
Aug 10, 2026
Merged

Add symbol metadata to outlined files#24
andrew merged 1 commit into
mainfrom
add-symbols

Conversation

@andrew

@andrew andrew commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Add top-level declaration metadata to outlined files without parsing source a second time. Each outlined File now includes ordered Symbol values 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.

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

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 Symbol extraction 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 Pack output 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 because NamedChildCount() is a numeric count, not a slice/map. Use an indexed loop over [0, NamedChildCount()).
    symbol.go:345
  • for i := range node.NamedChildCount() does not compile (numeric count). Switch to an indexed loop to iterate named children.
    symbol.go:381
  • for i := range value.NamedChildCount() does not compile because NamedChildCount() is a numeric count. Iterate with an indexed loop.
    symbol.go:397
  • for i := range node.NamedChildCount() does not compile (numeric count). Use an indexed loop when scanning direct children.
    symbol.go:413
  • for i := range node.NamedChildCount() in collectNames does not compile because NamedChildCount() is a numeric count. Use an indexed loop to recurse over children.
    symbol.go:419
  • for 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 thread symbol.go
Comment on lines +271 to +275
for i := range current.NamedChildCount() {
if visit(current.NamedChild(i)) {
return true
}
}
@andrew
andrew merged commit 067044f into main Aug 10, 2026
8 checks passed
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.

2 participants