refactor: factor tree-sitter symbol extraction into helpers (go, typescript)#17
Merged
Merged
Conversation
…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.
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.
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 theQueryCursormatch loop intoprivate free helpers, mirroring the reference pattern already used in
src/parser/rust.rs. The main loops are now pure dispatch.Changes
src/parser/go.rspush_go_import_edges(...)— the import-edge branch.build_go_symbol(...)— the per-matchSymbolconstruction body.build_signature/extract_docstringconverted from methods to freebuild_go_signature/extract_go_docstring(thread&Queryinstead of&self).src/parser/typescript.rspush_ts_import(...)andbuild_ts_symbol(...).build_signature,extract_jsdoc,is_exported,extract_import_names,extract_import_source).Fan-out (via
ctx complexity)go.rs::extract_symbolstypescript.rs::extract_symbolsCorrectness
Pure refactor — no test expectations changed.
cargo test— all pass (269 lib + integration suites green)cargo clippy -- -D warnings— cleanctx check— no architecture violations