summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKevin Newton <[email protected]>2023-12-01 12:06:57 -0500
committergit <[email protected]>2023-12-01 18:46:52 +0000
commitec83bd7356d639fe34f6843c4f1805c63cfdfa49 (patch)
tree3e1fad8fb3f5734f352154fa9adb912940eb2c42 /lib
parent2a8d9c59ff151e8e2274e5f788745e070111b8ab (diff)
[ruby/prism] Provide heredoc? queries
https://github.com/ruby/prism/commit/e148e8fe6a
Diffstat (limited to 'lib')
-rw-r--r--lib/prism/node_ext.rb57
1 files changed, 41 insertions, 16 deletions
diff --git a/lib/prism/node_ext.rb b/lib/prism/node_ext.rb
index 5fc13eb06d..8c09632345 100644
--- a/lib/prism/node_ext.rb
+++ b/lib/prism/node_ext.rb
@@ -14,8 +14,49 @@ module Prism
end
end
+ class InterpolatedMatchLastLineNode < Node
+ include RegularExpressionOptions
+ end
+
+ class InterpolatedRegularExpressionNode < Node
+ include RegularExpressionOptions
+ end
+
+ class MatchLastLineNode < Node
+ include RegularExpressionOptions
+ end
+
+ class RegularExpressionNode < Node
+ include RegularExpressionOptions
+ end
+
private_constant :RegularExpressionOptions
+ module HeredocQuery # :nodoc:
+ # Returns true if this node was represented as a heredoc in the source code.
+ def heredoc?
+ opening&.start_with?("<<")
+ end
+ end
+
+ class InterpolatedStringNode < Node
+ include HeredocQuery
+ end
+
+ class InterpolatedXStringNode < Node
+ include HeredocQuery
+ end
+
+ class StringNode < Node
+ include HeredocQuery
+ end
+
+ class XStringNode < Node
+ include HeredocQuery
+ end
+
+ private_constant :HeredocQuery
+
class FloatNode < Node
# Returns the value of the node as a Ruby Float.
def value
@@ -37,18 +78,6 @@ module Prism
end
end
- class InterpolatedMatchLastLineNode < Node
- include RegularExpressionOptions
- end
-
- class InterpolatedRegularExpressionNode < Node
- include RegularExpressionOptions
- end
-
- class MatchLastLineNode < Node
- include RegularExpressionOptions
- end
-
class RationalNode < Node
# Returns the value of the node as a Ruby Rational.
def value
@@ -56,10 +85,6 @@ module Prism
end
end
- class RegularExpressionNode < Node
- include RegularExpressionOptions
- end
-
class ConstantReadNode < Node
# Returns the list of parts for the full name of this constant.
# For example: [:Foo]