summaryrefslogtreecommitdiff
path: root/lib/prism/node_ext.rb
diff options
context:
space:
mode:
authorKevin Newton <[email protected]>2024-07-02 15:43:01 -0400
committerKevin Newton <[email protected]>2024-07-11 14:25:54 -0400
commit687be43c79a6fb119e52b09ea561cf958a9aabf2 (patch)
treedffa61a0172886f091571c73340926a70fe69340 /lib/prism/node_ext.rb
parentca48fb76fb0669ca0666a7aa129e1f5d2b7468da (diff)
[ruby/prism] Expose flags on every node type
https://github.com/ruby/prism/commit/9f12a56fd6
Diffstat (limited to 'lib/prism/node_ext.rb')
-rw-r--r--lib/prism/node_ext.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/prism/node_ext.rb b/lib/prism/node_ext.rb
index fe36be8541..30ab652384 100644
--- a/lib/prism/node_ext.rb
+++ b/lib/prism/node_ext.rb
@@ -21,7 +21,10 @@ module Prism
# Returns a numeric value that represents the flags that were used to create
# the regular expression.
def options
- o = flags & (RegularExpressionFlags::IGNORE_CASE | RegularExpressionFlags::EXTENDED | RegularExpressionFlags::MULTI_LINE)
+ o = 0
+ o |= Regexp::IGNORECASE if flags.anybits?(RegularExpressionFlags::IGNORE_CASE)
+ o |= Regexp::EXTENDED if flags.anybits?(RegularExpressionFlags::EXTENDED)
+ o |= Regexp::MULTILINE if flags.anybits?(RegularExpressionFlags::MULTI_LINE)
o |= Regexp::FIXEDENCODING if flags.anybits?(RegularExpressionFlags::EUC_JP | RegularExpressionFlags::WINDOWS_31J | RegularExpressionFlags::UTF_8)
o |= Regexp::NOENCODING if flags.anybits?(RegularExpressionFlags::ASCII_8BIT)
o
@@ -87,6 +90,7 @@ module Prism
InterpolatedXStringNode.new(
source,
location,
+ flags,
opening_loc,
[StringNode.new(source, content_loc, 0, nil, content_loc, nil, unescaped)],
closing_loc
@@ -117,7 +121,7 @@ module Prism
if denominator == 1
IntegerNode.new(source, location.chop, flags, numerator)
else
- FloatNode.new(source, location.chop, numerator.to_f / denominator)
+ FloatNode.new(source, location.chop, 0, numerator.to_f / denominator)
end
end
end
@@ -195,7 +199,7 @@ module Prism
# continue to supply that API.
def child
deprecated("name", "name_loc")
- name ? ConstantReadNode.new(source, name_loc, name) : MissingNode.new(source, location)
+ name ? ConstantReadNode.new(source, name_loc, 0, name) : MissingNode.new(source, location, 0)
end
end
@@ -231,7 +235,7 @@ module Prism
# continue to supply that API.
def child
deprecated("name", "name_loc")
- name ? ConstantReadNode.new(source, name_loc, name) : MissingNode.new(source, location)
+ name ? ConstantReadNode.new(source, name_loc, 0, name) : MissingNode.new(source, location, 0)
end
end