Skip to content

Commit

Permalink
[ruby/prism] Prism::CallNode#full_message_loc
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton authored and matzbot committed May 10, 2024
1 parent c68bb24 commit 3f664c3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/prism/node_ext.rb
Expand Up @@ -286,4 +286,19 @@ def signature
names
end
end

class CallNode < Node
# When a call node has the attribute_write flag set, it means that the call
# is using the attribute write syntax. This is either a method call to []=
# or a method call to a method that ends with =. Either way, the = sign is
# present in the source.
#
# Prism returns the message_loc _without_ the = sign attached, because there
# can be any amount of space between the message and the = sign. However,
# sometimes you want the location of the full message including the inner
# space and the = sign. This method provides that.
def full_message_loc
attribute_write? ? message_loc&.adjoin("=") : message_loc
end
end
end

0 comments on commit 3f664c3

Please sign in to comment.