Skip to content

refactor: collapse solidity parser Symbol construction into a helper#16

Merged
saldestechnology merged 1 commit into
mainfrom
refactor/solidity-symbol-builder
Jul 10, 2026
Merged

refactor: collapse solidity parser Symbol construction into a helper#16
saldestechnology merged 1 commit into
mainfrom
refactor/solidity-symbol-builder

Conversation

@saldestechnology

Copy link
Copy Markdown
Collaborator

Summary

Behavior-preserving refactor of the two highest-complexity functions in the codebase, both in src/parser/solidity.rs. Each of the 10 Symbol { … } match-arm literals repeated the identical setup (loc_to_linesfind_doc_commentextract_briefSymbol::make_id → build the 15-field struct with extract_source), which drove the fan-out.

Adds one private push_symbol helper that performs that dance once, and replaces all 10 inline construction sites in parse and extract_contract_parts with thin dispatch calls. Top-level symbols pass parent = None (no qualified_name/parent_id); contract members pass Some((contract_name, contract_id)). kind and visibility stay per-arm.

Before / after fan-out

Function Before After
parse 81 36
extract_contract_parts 84 24

ctx score --against main: complexity delta -199, fan-out delta -91, new duplication 0, check violations 0, +1 symbol (push_symbol). Net -52 lines.

Correctness

Pure refactor — every field value is preserved exactly, and no test expectations were changed.

  • cargo test --verbose: all pass (269 unit + all integration suites green, incl. the solidity parser tests)
  • cargo clippy -- -D warnings: clean
  • ctx check: no architecture violations

Collapse the repeated loc_to_lines/find_doc_comment/extract_brief/
make_id/extract_source dance and 15-field Symbol literals into a single
private push_symbol helper. Replaces all 10 inline construction sites in
parse and extract_contract_parts with thin dispatch calls.

Behavior-preserving: all field values are unchanged; existing tests pass.
Fan-out drops parse 81->36 and extract_contract_parts 84->24.
@saldestechnology
saldestechnology merged commit 56d7559 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