summaryrefslogtreecommitdiff
path: root/lib/prism
diff options
context:
space:
mode:
authorKevin Newton <[email protected]>2024-07-03 10:42:56 -0400
committerKevin Newton <[email protected]>2024-07-11 14:25:54 -0400
commit2bf9ae3fa1b5dec1c63176f39db84d697ede3581 (patch)
treeff1b62681ac40f7cc121bdd55a979f9bb27ed15c /lib/prism
parent39dcfe26ee55919c3277a59884592a0ebe0aee6a (diff)
[ruby/prism] Add node ids to nodes
https://github.com/ruby/prism/commit/bf16ade7f9
Diffstat (limited to 'lib/prism')
-rw-r--r--lib/prism/node_ext.rb22
1 files changed, 17 insertions, 5 deletions
diff --git a/lib/prism/node_ext.rb b/lib/prism/node_ext.rb
index 30ab652384..354bfdb205 100644
--- a/lib/prism/node_ext.rb
+++ b/lib/prism/node_ext.rb
@@ -72,6 +72,7 @@ module Prism
def to_interpolated
InterpolatedStringNode.new(
source,
+ -1,
location,
frozen? ? InterpolatedStringNodeFlags::FROZEN : 0,
opening_loc,
@@ -89,10 +90,11 @@ module Prism
def to_interpolated
InterpolatedXStringNode.new(
source,
+ -1,
location,
flags,
opening_loc,
- [StringNode.new(source, content_loc, 0, nil, content_loc, nil, unescaped)],
+ [StringNode.new(source, node_id, content_loc, 0, nil, content_loc, nil, unescaped)],
closing_loc
)
end
@@ -119,9 +121,9 @@ module Prism
deprecated("value", "numerator", "denominator")
if denominator == 1
- IntegerNode.new(source, location.chop, flags, numerator)
+ IntegerNode.new(source, -1, location.chop, flags, numerator)
else
- FloatNode.new(source, location.chop, 0, numerator.to_f / denominator)
+ FloatNode.new(source, -1, location.chop, 0, numerator.to_f / denominator)
end
end
end
@@ -199,7 +201,12 @@ module Prism
# continue to supply that API.
def child
deprecated("name", "name_loc")
- name ? ConstantReadNode.new(source, name_loc, 0, name) : MissingNode.new(source, location, 0)
+
+ if name
+ ConstantReadNode.new(source, -1, name_loc, 0, name)
+ else
+ MissingNode.new(source, -1, location, 0)
+ end
end
end
@@ -235,7 +242,12 @@ module Prism
# continue to supply that API.
def child
deprecated("name", "name_loc")
- name ? ConstantReadNode.new(source, name_loc, 0, name) : MissingNode.new(source, location, 0)
+
+ if name
+ ConstantReadNode.new(source, -1, name_loc, 0, name)
+ else
+ MissingNode.new(source, -1, location, 0)
+ end
end
end