@@ -4813,7 +4813,7 @@ class Heredoc < Node
48134813 # [HeredocBeg] the opening of the heredoc
48144814 attr_reader :beginning
48154815
4816- # [String ] the ending of the heredoc
4816+ # [HeredocEnd ] the ending of the heredoc
48174817 attr_reader :ending
48184818
48194819 # [Integer] how far to dedent the heredoc
@@ -4847,7 +4847,7 @@ def accept(visitor)
48474847 end
48484848
48494849 def child_nodes
4850- [ beginning , *parts ]
4850+ [ beginning , *parts , ending ]
48514851 end
48524852
48534853 alias deconstruct child_nodes
@@ -4883,7 +4883,7 @@ def format(q)
48834883 end
48844884 end
48854885
4886- q . text ( ending )
4886+ q . format ( ending )
48874887 end
48884888 end
48894889 end
@@ -4929,6 +4929,45 @@ def format(q)
49294929 end
49304930 end
49314931
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+
49324971 # HshPtn represents matching against a hash pattern using the Ruby 2.7+
49334972 # pattern matching syntax.
49344973 #
0 commit comments