Reapply "[ruby/rdoc] fix: C variables should never show up in Ancestors tree"
This reverts commit 0fe82ae087130d7f360cc0607be93995cedbdb16.
This commit is contained in:
parent
59d23174c0
commit
d85e8b5339
Notes:
git
2024-12-03 01:59:52 +00:00
@ -415,6 +415,8 @@ The internal error was:
|
|||||||
parse_file filename
|
parse_file filename
|
||||||
end.compact
|
end.compact
|
||||||
|
|
||||||
|
@store.resolve_c_superclasses
|
||||||
|
|
||||||
@stats.done_adding
|
@stats.done_adding
|
||||||
@options = original_options
|
@options = original_options
|
||||||
|
|
||||||
|
@ -197,6 +197,18 @@ class RDoc::Store
|
|||||||
top_level
|
top_level
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Make sure any references to C variable names are resolved to the corresponding class.
|
||||||
|
#
|
||||||
|
|
||||||
|
def resolve_c_superclasses
|
||||||
|
@classes_hash.each_value do |klass|
|
||||||
|
if klass.superclass.is_a?(String) && (candidate = find_c_enclosure(klass.superclass))
|
||||||
|
klass.superclass = candidate
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Sets the parser of +absolute_name+, unless it from a source code file.
|
# Sets the parser of +absolute_name+, unless it from a source code file.
|
||||||
|
|
||||||
|
@ -281,6 +281,26 @@ class TestRDocStore < XrefTestCase
|
|||||||
assert_nil @s.find_c_enclosure('cObject')
|
assert_nil @s.find_c_enclosure('cObject')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_resolve_c_superclasses
|
||||||
|
# first parse a child that references an unknown parent
|
||||||
|
c_file1 = @s.add_file 'ext1.c'
|
||||||
|
c_file1.add_class RDoc::NormalClass, 'Child', 'cExternParent'
|
||||||
|
|
||||||
|
# then parse the parent and register the C variable name as a C enclosure
|
||||||
|
c_file2 = @s.add_file 'ext2.c'
|
||||||
|
parent = c_file2.add_class RDoc::NormalClass, 'Parent', 'rb_cObject'
|
||||||
|
|
||||||
|
@s.add_c_enclosure('cExternParent', parent)
|
||||||
|
|
||||||
|
# at this point, the child's superclass is still the name of the C variable
|
||||||
|
assert_equal("cExternParent", @s.classes_hash['Child'].superclass)
|
||||||
|
|
||||||
|
@s.resolve_c_superclasses
|
||||||
|
|
||||||
|
# now the ancestor tree correctly references the NormalClass objects
|
||||||
|
assert_equal(parent, @s.classes_hash['Child'].superclass)
|
||||||
|
end
|
||||||
|
|
||||||
def test_find_class_named
|
def test_find_class_named
|
||||||
assert_equal @c1, @store.find_class_named('C1')
|
assert_equal @c1, @store.find_class_named('C1')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user