mirror of
https://github.com/ruby/ruby.git
synced 2025-09-21 03:24:00 +02:00
parent
5d73c0f3df
commit
c0f162caab
3 changed files with 16 additions and 9 deletions
|
@ -100,9 +100,7 @@ module YARP
|
|||
comment_end = comment.location.end_offset
|
||||
|
||||
targets = []
|
||||
node.deconstruct_keys(nil).each do |key, value|
|
||||
next if key == :location
|
||||
|
||||
node.comment_targets.map do |value|
|
||||
case value
|
||||
when StatementsNode
|
||||
targets.concat(value.body.map { |node| NodeTarget.new(node) })
|
||||
|
@ -110,8 +108,6 @@ module YARP
|
|||
targets << NodeTarget.new(value)
|
||||
when Location
|
||||
targets << LocationTarget.new(value)
|
||||
when Array
|
||||
targets.concat(value.map { |node| NodeTarget.new(node) }) if value.first.is_a?(Node)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -166,6 +162,8 @@ module YARP
|
|||
end
|
||||
end
|
||||
|
||||
private_constant :Comments
|
||||
|
||||
# Attach the list of comments to their respective locations in the tree.
|
||||
def attach_comments!
|
||||
Comments.new(self).attach!
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue