Skip to content

refactor(parser): split relations.rs (2783 lines) into 9-module per-concern tree#16

Merged
sdsrss merged 1 commit into
mainfrom
refactor/split-relations-rs
May 9, 2026
Merged

refactor(parser): split relations.rs (2783 lines) into 9-module per-concern tree#16
sdsrss merged 1 commit into
mainfrom
refactor/split-relations-rs

Conversation

@sdsrss
Copy link
Copy Markdown
Owner

@sdsrss sdsrss commented May 9, 2026

Summary

  • Splits src/parser/relations.rs (2783 lines) into src/parser/relations/{mod,helpers,imports,inherits,exports,routes,rust,dart,tests}.rs. Mirrors the per-domain split landed for queries.rs in refactor(storage): split queries.rs into 10-module per-domain tree #15.
  • mod.rs (722 lines) keeps the giant walk_for_relations dispatch as one match — its arms share current_scope / current_class propagation, so splitting per-language would either duplicate recursion or lose scope context.
  • Public surface unchanged: extract_relations, extract_relations_from_tree, ParsedRelation. pipeline.rs and tests/parser_deep_test.rs need no edits.
File Lines Concern
mod.rs 722 walker dispatcher + entry points
helpers.rs 75 extract_callee_name + string-literal subtree lookup
imports.rs 229 generic JS/TS/Java + Python import shapes
inherits.rs 231 extract_superclasses + extract_implements across class-style langs
exports.rs 61 TS/JS export statements
routes.rs 182 Express + Go + Python HTTP route registration
rust.rs 108 use declarations + impl Trait for Type
dart.rs 136 Dart imports + call expressions
tests.rs 1138 all #[cfg(test)] tests

Submodule items use pub(super); mod.rs re-imports what each walker arm needs.

Test plan

  • cargo check — clean
  • cargo +1.95.0 clippy --no-default-features -- -D warnings — clean
  • cargo +1.95.0 clippy --all-targets -- -D warnings — clean
  • cargo test --release — 415 tests, 0 failed (1 pre-existing #[ignore])
  • CI green on PR

🤖 Generated with Claude Code

src/parser/relations.rs (2783 lines) → src/parser/relations/{mod,helpers,
imports,inherits,exports,routes,rust,dart,tests}.rs. mod.rs (722 lines)
keeps the giant walk_for_relations dispatch — its match arms share
current_scope/current_class propagation, so splitting per-language would
either duplicate the recursion or lose scope context.

Per-concern submodules:
  helpers.rs   (75)   — extract_callee_name, extract_string_from_subtree
  imports.rs   (229)  — generic JS/TS/Java + Python imports
  inherits.rs  (231)  — extract_superclasses + extract_implements (multi-lang)
  exports.rs   (61)   — TS/JS export statements
  routes.rs    (182)  — Express + Go + Python HTTP route extraction
  rust.rs      (108)  — Rust use-imports + impl Trait for Type
  dart.rs      (136)  — Dart imports + call expressions
  tests.rs     (1138) — all #[cfg(test)] tests

Public surface unchanged (extract_relations / extract_relations_from_tree
/ ParsedRelation), so pipeline.rs and tests/parser_deep_test.rs need no
edits. Submodule items are pub(super); mod.rs re-imports what walker arms
need.

Verification:
- cargo check: clean
- cargo +1.95.0 clippy --no-default-features -- -D warnings: clean
- cargo +1.95.0 clippy --all-targets -- -D warnings: clean
- cargo test --release: 292 lib + 44 + 19 + 6 + 54 = 415 tests, 0 failed
  (1 pre-existing #[ignore])

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

Warning

Rate limit exceeded

@sdsrss has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 34 minutes and 4 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 16b8929f-3232-4b9b-9249-084d820d3c2f

📥 Commits

Reviewing files that changed from the base of the PR and between 657a1f9 and d6dd207.

📒 Files selected for processing (10)
  • src/parser/relations.rs
  • src/parser/relations/dart.rs
  • src/parser/relations/exports.rs
  • src/parser/relations/helpers.rs
  • src/parser/relations/imports.rs
  • src/parser/relations/inherits.rs
  • src/parser/relations/mod.rs
  • src/parser/relations/routes.rs
  • src/parser/relations/rust.rs
  • src/parser/relations/tests.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/split-relations-rs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sdsrss sdsrss merged commit 2dfbab9 into main May 9, 2026
9 checks passed
@sdsrss sdsrss deleted the refactor/split-relations-rs branch May 9, 2026 20:55
sdsrss added a commit that referenced this pull request May 9, 2026
…/ pipeline)

Pure refactor release — three biggest source files (8049 lines as monoliths)
decomposed into 26 per-concern submodules. Zero behavior change, public
surface preserved across all three splits.

- src/storage/queries.rs (2892 lines) → src/storage/queries/ (10 files, #15)
- src/parser/relations.rs (2783 lines) → src/parser/relations/ (9 files, #16)
- src/indexer/pipeline.rs (2374 lines) → src/indexer/pipeline/ (7 files, #17)

External callers in cli.rs / mcp/server / tests / benches / claude-plugin
keep their imports unchanged. Two orchestrator-style functions kept whole
deliberately (walk_for_relations ~650 lines, index_files ~770 lines) — their
arms/phases share local state that splitting would either duplicate or thread
back via large arg lists.

Verification: cargo check + cargo +1.95.0 clippy (no-default-features +
all-targets, -D warnings) + cargo test --release (292 lib + 129 integration
= 421 tests, 0 failed). Pre-merge CI green on all three PRs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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