You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Store sidecar .rbs signatures separately from method objects
Sidecar .rbs signatures were being merged into MethodAttr#type_signature_lines
during load, which forced the store to keep a @rbs_signature_method_attrs
tracker so reloads could clear the previously-assigned signatures. Method
objects ended up owning data that didn't come from their source file, and
every reload had to undo that mutation.
Move the signatures to a dedicated @rbs_signatures hash on the store and
look them up at render time:
* Store#merge_rbs_signatures now just stores the hash; the iteration over
every class and method is gone.
* Store#rbs_signature_for(method_attr) does the lookup, including the
initialize -> .new singleton mapping and the alias fallthrough to the
canonical method.
* Store#clear_rbs_signatures becomes a one-liner setting the hash to nil.
* The @rbs_signature_method_attrs tracker is deleted along with
assign_rbs_signature, and the unused rbs_key helper is gone too.
Read sites use `method.type_signature_lines || store.rbs_signature_for(method)`
so inline `#:` annotations still win over sidecar signatures:
* Generator::Aliki#type_signature_html — falls back to the store lookup.
* aliki/class.rhtml — computes the HTML once via `if (sig_html = ...)`.
* RI::Driver — same `||` fallthrough before rendering.
With the mutation gone, the server's reparse_and_refresh no longer needs
to call load_rbs_signatures when only .rb files change. Newly-added
methods resolve through the existing string-keyed hash at render time, so
the reload is only required when .rbs files themselves change. Ordering
between load and Store#complete no longer matters either; reverse the two
in rdoc.rb and server.rb so the flow reads "load all data, then finalize."
Tests in rdoc_store_test.rb assert the new lookup path; two integration
tests (rdoc_rdoc_test, rdoc_server_test) follow suit. Two new tests pin
the invariants: sidecar load doesn't touch inline #: lines, and lookups
return nil when no signatures are loaded. The old
test_merge_rbs_signatures_does_not_overwrite_inline_annotations is gone —
it became tautological once merge stopped touching method objects, and
the new test_rbs_signature_for_does_not_overwrite_inline_lookup already
pins the meaningful invariant.
0 commit comments