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:

  • if statements

  • unless statements

  • nodes that are children of statements lists

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.

Class Methods

Create a new Newlines visitor with the given newline offsets.

Instance Methods

Permit block/lambda nodes to mark newlines within themselves.

Mark if/unless nodes as newlines.

An alias for visit_block_node

Permit statements lists to mark newlines within themselves.

An alias for visit_if_node