refactor(symbols): decompose god class, extract shared utilities#83
Merged
zbigniewsobiecki merged 1 commit intodevfrom Apr 7, 2026
Merged
Conversation
- Extract resolveFileId helper from 5+ files into _shared/file-resolver.ts - Decompose 724-line symbols/show.ts into data-gatherer + renderer + thin orchestrator - Extract duplicate countArguments into src/parser/_shared/ast-utils.ts - Add 22 new unit tests for resolveFileId and SymbolShowDataGatherer Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
nhopeatall
approved these changes
Apr 7, 2026
Collaborator
nhopeatall
left a comment
There was a problem hiding this comment.
LGTM — Clean, well-executed decomposition of a 724-line god class into focused modules with proper shared utility extraction.
Verified:
- resolveFileId is behaviorally equivalent to the inline patterns it replaces across all 5 call sites
- countArguments extraction is identical between the two former copies
- JSON output shape is preserved: the new inline module mapping matches what formatModuleRef returned
- The SymbolShowRenderer output matches the old rendering methods line-for-line
- CI green (lint + tests + type-check)
The data-gatherer/renderer split makes SymbolShowDataGatherer independently testable (demonstrated by the 22 new tests), which is a meaningful improvement over the old monolithic command class.
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
Refactors the 724-line
symbols/show.tsgod command and eliminates duplicated patterns found across the codebase.resolveFileIdshared helper — Consolidates the repeatedgetIdByPath(toRelativePath(...)) ?? getIdByPath(...)pattern from 5 files into a singlesrc/commands/_shared/file-resolver.tsutilitysymbols/show.tsinto three focused files: a data-gathering class (_show-data.ts), a renderer class (_show-renderer.ts), and a thin orchestrator (~95 lines, down from 724)countArguments— Extracts the identical function fromreference-extractor.tsandpure-check.tsintosrc/parser/_shared/ast-utils.tsresolveFileIdandSymbolShowDataGathererFiles changed
New files
src/commands/_shared/file-resolver.ts— sharedresolveFileIdhelpersrc/commands/symbols/_show-data.ts—SymbolShowDataGathererclass + typed interfaces (SymbolShowData,FileShowData)src/commands/symbols/_show-renderer.ts—SymbolShowRendererclasssrc/parser/_shared/ast-utils.ts— sharedcountArgumentsutilitytest/commands/_shared/file-resolver.test.ts— unit tests for resolveFileIdtest/commands/symbols/show-data.test.ts— unit tests for SymbolShowDataGathererModified files
src/commands/symbols/show.ts— reduced to ~95-line thin orchestratorsrc/commands/_shared/index.ts— exportsresolveFileIdsrc/commands/files/imports.ts,imported-by.ts,show.ts— useresolveFileIdsrc/commands/symbols/list.ts— usesresolveFileIdsrc/parser/reference-extractor.ts— importscountArgumentsfrom shared modulesrc/commands/llm/_shared/pure-check.ts— importscountArgumentsfrom shared moduleTest plan
Card
https://trello.com/c/69d54e09708468ab629905e2