@@ -4813,7 +4813,7 @@ class Heredoc < Node
4813
4813
# [HeredocBeg] the opening of the heredoc
4814
4814
attr_reader :beginning
4815
4815
4816
- # [String ] the ending of the heredoc
4816
+ # [HeredocEnd ] the ending of the heredoc
4817
4817
attr_reader :ending
4818
4818
4819
4819
# [Integer] how far to dedent the heredoc
@@ -4847,7 +4847,7 @@ def accept(visitor)
4847
4847
end
4848
4848
4849
4849
def child_nodes
4850
- [ beginning , *parts ]
4850
+ [ beginning , *parts , ending ]
4851
4851
end
4852
4852
4853
4853
alias deconstruct child_nodes
@@ -4883,7 +4883,7 @@ def format(q)
4883
4883
end
4884
4884
end
4885
4885
4886
- q . text ( ending )
4886
+ q . format ( ending )
4887
4887
end
4888
4888
end
4889
4889
end
@@ -4929,6 +4929,45 @@ def format(q)
4929
4929
end
4930
4930
end
4931
4931
4932
+ # HeredocEnd represents the closing declaration of a heredoc.
4933
+ #
4934
+ # <<~DOC
4935
+ # contents
4936
+ # DOC
4937
+ #
4938
+ # In the example above the HeredocEnd node represents the closing DOC.
4939
+ class HeredocEnd < Node
4940
+ # [String] the closing declaration of the heredoc
4941
+ attr_reader :value
4942
+
4943
+ # [Array[ Comment | EmbDoc ]] the comments attached to this node
4944
+ attr_reader :comments
4945
+
4946
+ def initialize ( value :, location :, comments : [ ] )
4947
+ @value = value
4948
+ @location = location
4949
+ @comments = comments
4950
+ end
4951
+
4952
+ def accept ( visitor )
4953
+ visitor . visit_heredoc_end ( self )
4954
+ end
4955
+
4956
+ def child_nodes
4957
+ [ ]
4958
+ end
4959
+
4960
+ alias deconstruct child_nodes
4961
+
4962
+ def deconstruct_keys ( _keys )
4963
+ { value : value , location : location , comments : comments }
4964
+ end
4965
+
4966
+ def format ( q )
4967
+ q . text ( value )
4968
+ end
4969
+ end
4970
+
4932
4971
# HshPtn represents matching against a hash pattern using the Ruby 2.7+
4933
4972
# pattern matching syntax.
4934
4973
#
0 commit comments