summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2024-05-10 09:27:59 -0400
committergit <svn-admin@ruby-lang.org>2024-05-10 13:40:04 +0000
commit3f664c3738fe25227b9d990064e4b5fda2d84c39 (patch)
treecf5808b57614f809296b0a09d1a8708d11811346
parentc68bb2408829ffdac2465f38a1d040b7f1e1c6aa (diff)
[ruby/prism] Prism::CallNode#full_message_loc
https://github.com/ruby/prism/commit/fa6fe9be84
-rw-r--r--lib/prism/node_ext.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/prism/node_ext.rb b/lib/prism/node_ext.rb
index d4c9b21079..13830dad3d 100644
--- a/lib/prism/node_ext.rb
+++ b/lib/prism/node_ext.rb
@@ -286,4 +286,19 @@ module Prism
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