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
Replace alias-path regex with parser-supplied AST info
The lazy resolver previously inspected RDoc::Constant#value with a regex
to guess whether the RHS looked like a constant path. Both parsers
already know this from the AST/token stream:
* The Prism parser distinguishes ConstantReadNode/ConstantPathNode
values via constant_path_string in lib/rdoc/parser/prism_ruby.rb.
* The legacy ripper parser only builds rhs_name from :on_const and `::`
tokens in lib/rdoc/parser/ripper_ruby.rb, so reaching
create_module_alias already implies the RHS is a constant path.
Track that explicit knowledge on the constant via a new
RDoc::Constant#is_alias_for_path attribute and drop the regex from
#resolved_alias_target. The lazy resolver now activates only when the
parser actually saw a constant reference, which is more accurate than
the regex (no false positives on string-shaped values that happen to
match) and removes a one-off pattern that was duplicated work.
Tests:
* Each parser-level test that asserts a real class is preserved now
also asserts that the would-be alias target (Bar, Bar::Foo) keeps its
own methods and doesn't end up in someone else's #aliases.
* The unit-level update_aliases tests assert the same: the would-be
target keeps its method list and aliases stay empty.
These positive assertions guard against a future regression where the
real class survives but the alias target is somehow corrupted or has
its aliases list mutated.
0 commit comments