Skip to content

Commit 696bc87

Browse files
committed
Support slices change in Prism
Support upcoming Prism change. If a node of incomplete code doesn't have closing, node.closing will be nil instead of an empty string.
1 parent 92773bc commit 696bc87

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

lib/irb/nesting_parser.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def close_end_keyword_loc(node)
7575
end
7676

7777
def close_closing_loc(node)
78-
close_location(node.closing_loc) unless node.closing.nil? || node.closing.empty?
78+
close_location(node.closing_loc) if node.closing_loc && !node.closing.empty?
7979
end
8080

8181
def visit_for_node(node)
@@ -220,7 +220,7 @@ def heredoc_string_like(node, type)
220220
if node.opening&.start_with?('<<')
221221
heredoc_open(node)
222222
# Heredoc closing contains trailing newline. We need to exclude it
223-
close_location_start(node.closing_loc) unless node.closing.empty?
223+
close_location_start(node.closing_loc) if node.closing_loc && !node.closing.empty?
224224
elsif node.opening
225225
open_location(node.location, type, node.opening)
226226
if node.closing && node.closing != ''
@@ -283,7 +283,7 @@ def visit_call_node(node)
283283

284284
if type
285285
open_location(node.opening_loc, type, node.opening)
286-
close_location(node.closing_loc) unless node.closing.empty?
286+
close_closing_loc(node)
287287
end
288288
end
289289

@@ -298,7 +298,7 @@ def visit_block_parameters_node(node)
298298
def visit_lambda_node(node)
299299
super
300300
open_location(node.opening_loc, :on_tlambeg, node.opening)
301-
close_location(node.closing_loc) unless node.closing.empty?
301+
close_closing_loc(node)
302302
end
303303

304304
def visit_super_node(node)

0 commit comments

Comments
 (0)