Skip to content

Commit 075f607

Browse files
committed
Clear memoized method/attribute caches on re-parse
After clearing methods and attributes from a file in clear_file_contributions, the memoized lists (@instance_methods, @class_method_list, @instance_attributes, @class_attributes) still held stale data, causing the sidebar navigation to show outdated entries when methods were added or removed.
1 parent ecd479f commit 075f607

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/rdoc/store.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,12 @@ def clear_file_contributions(relative_name, keep_position: false)
234234
cm.method_list.each { |m| cm.methods_hash[m.pretty_name] = m }
235235
cm.attributes.each { |a| cm.methods_hash[a.pretty_name] = a }
236236

237+
# Clear memoized method/attribute lists so they rebuild from current data
238+
cm.instance_variable_set(:@instance_methods, nil)
239+
cm.instance_variable_set(:@class_method_list, nil)
240+
cm.instance_variable_set(:@instance_attributes, nil)
241+
cm.instance_variable_set(:@class_attributes, nil)
242+
237243
# Remove constants contributed by this file
238244
cm.constants.reject! { |c| c.file == top_level }
239245
cm.constants_hash.clear

0 commit comments

Comments
 (0)