Decouple Store internals from CodeObject classes#1622
Draft
Conversation
Collaborator
|
🚀 Preview deployment available at: https://2e3e1cc7.rdoc-6cd.pages.dev (commit: c583935) |
Move resolution logic out of CodeObjects into Store: - Add `Store#resolve_parent` to encapsulate lazy parent loading (previously `CodeObject#parent` called `load_class` for disk I/O) - Add `Store#resolve_mixin` to encapsulate namespace-walking (previously 30 lines of scoping logic lived in `Mixin#module`) Consolidate file normalization in base `CodeObject#store=`: - Remove redundant `store=` overrides from `MethodAttr`, `AnyMethod`, `Mixin`, and `Constant` that all did identical `add_file` calls - Fix pre-existing bug where `AnyMethod` called `add_file` twice Replace direct hash reads with existing finder methods: - Use `find_class_or_module`, `find_class_named`, `find_module_named` instead of `@store.classes_hash[]` / `@store.modules_hash[]` Simplify `add_class_or_module` signature: - Drop the `all_hash` parameter that passed Store's internal hash by reference; method now registers directly via the hash accessors
294e0bd to
c583935
Compare
st0012
commented
Feb 22, 2026
| @parser.parse_method m, RDoc::Parser::Ruby::NORMAL, tk, @comment | ||
|
|
||
| assert_empty @store.modules_hash.keys | ||
| assert_equal %w[M], @store.classes_hash.keys |
Member
Author
There was a problem hiding this comment.
I think the test was wrong: if M is added as a NormalModule, it should appear in the modules hash, not classes hash.
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.
Move resolution logic out of CodeObjects into Store:
Store#resolve_parentto encapsulate lazy parent loading (previouslyCodeObject#parentcalledload_classfor disk I/O)Store#resolve_mixinto encapsulate namespace-walking (previously 30 lines of scoping logic lived inMixin#module)Consolidate file normalization in base
CodeObject#store=:store=overrides fromMethodAttr,AnyMethod,Mixin, andConstantthat all did identicaladd_filecallsAnyMethodcalledadd_filetwiceReplace direct hash reads with existing finder methods:
find_class_or_module,find_class_named,find_module_namedinstead of@store.classes_hash[]/@store.modules_hash[]Simplify
add_class_or_modulesignature:all_hashparameter that passed Store's internal hash by reference; method now registers directly via the hash accessors