refactor: collapse solidity parser Symbol construction into a helper#16
Merged
Merged
Conversation
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.
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 of the two highest-complexity functions in the codebase, both in
src/parser/solidity.rs. Each of the 10Symbol { … }match-arm literals repeated the identical setup (loc_to_lines→find_doc_comment→extract_brief→Symbol::make_id→ build the 15-field struct withextract_source), which drove the fan-out.Adds one private
push_symbolhelper that performs that dance once, and replaces all 10 inline construction sites inparseandextract_contract_partswith thin dispatch calls. Top-level symbols passparent = None(noqualified_name/parent_id); contract members passSome((contract_name, contract_id)).kindandvisibilitystay per-arm.Before / after fan-out
parseextract_contract_partsctx 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: cleanctx check: no architecture violations