class Prism::ParseResult::Newlines

The :line tracepoint event gets fired whenever the Ruby VM encounters an expression on a new line. The types of expressions that can trigger this event are:

In order to keep track of the newlines, we have a list of offsets that come back from the parser. We assign these offsets to the first nodes that we find in the tree that are on those lines.

Note that the logic in this file should be kept in sync with the Java MarkNewlinesVisitor, since that visitor is responsible for marking the newlines for JRuby/TruffleRuby.

This file is autoloaded only when mark_newlines! is called, so the re-opening of the various nodes in this file will only be performed in that case. We do that to avoid storing the extra @newline instance variable on every node if we don’t need it.