Skip to content

refactor: factor tree-sitter symbol extraction into helpers (go, typescript)#17

Merged
saldestechnology merged 1 commit into
mainfrom
refactor/tree-sitter-extract-symbols
Jul 10, 2026
Merged

refactor: factor tree-sitter symbol extraction into helpers (go, typescript)#17
saldestechnology merged 1 commit into
mainfrom
refactor/tree-sitter-extract-symbols

Conversation

@saldestechnology

Copy link
Copy Markdown
Collaborator

Summary

Behavior-preserving refactor that reduces the fan-out/complexity of the two
long tree-sitter symbol extractors by factoring their inline
Symbol/Edge/import construction out of the QueryCursor match loop into
private free helpers, mirroring the reference pattern already used in
src/parser/rust.rs. The main loops are now pure dispatch.

Changes

src/parser/go.rs

  • New push_go_import_edges(...) — the import-edge branch.
  • New build_go_symbol(...) — the per-match Symbol construction body.
  • build_signature / extract_docstring converted from methods to free
    build_go_signature / extract_go_docstring (thread &Query instead of &self).

src/parser/typescript.rs

  • New push_ts_import(...) and build_ts_symbol(...).
  • Reuses the existing free helpers (build_signature, extract_jsdoc,
    is_exported, extract_import_names, extract_import_source).

Fan-out (via ctx complexity)

function before after
go.rs::extract_symbols 61 17
typescript.rs::extract_symbols 48 25

Correctness

Pure refactor — no test expectations changed.

  • cargo test — all pass (269 lib + integration suites green)
  • cargo clippy -- -D warnings — clean
  • ctx check — no architecture violations
  • New duplication: 0

…rsers

Factor the inline Symbol/Edge/import construction out of the long
QueryCursor match loops in the Go and TypeScript symbol extractors into
private free helpers, mirroring the pattern in rust.rs. The main loops
now just dispatch.

- go.rs: add push_go_import_edges and build_go_symbol; convert
  build_signature/extract_docstring to free build_go_signature/
  extract_go_docstring. extract_symbols fan-out 61 -> 17.
- typescript.rs: add push_ts_import and build_ts_symbol, reusing the
  existing free helpers. extract_symbols fan-out 48 -> 25.

Behavior-preserving: all existing parser tests unchanged and green,
clippy clean, ctx check reports no violations.
@saldestechnology
saldestechnology merged commit 8c081c3 into main Jul 10, 2026
5 checks passed
saldestechnology added a commit that referenced this pull request Jul 10, 2026
Auto-wire ctx hooks into .claude/settings.json on 'harness init'
(#19), plus internal Solidity/Go/TypeScript parser refactors
(#16, #17). Move Unreleased changelog entries to 0.3.1 and update
comparison links.
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.

1 participant