class Prism::ParseResult::Newlines
newlines for JRuby/TruffleRuby.
MarkNewlinesVisitor, since that visitor is responsible for marking the
Note that the logic in this file should be kept in sync with the Java
we find in the tree that are on those lines.
come back from the parser. We assign these offsets to the first nodes that
In order to keep track of the newlines, we have a list of offsets that
* nodes that are children of statements lists
* unless statements
* if statements
event are:
expression on a new line. The types of expressions that can trigger this
The :line tracepoint event gets fired whenever the Ruby VM encounters an
def initialize(newline_marked)
def initialize(newline_marked) @newline_marked = newline_marked end
def visit_block_node(node)
def visit_block_node(node) old_newline_marked = @newline_marked @newline_marked = Array.new(old_newline_marked.size, false) begin super(node) ensure @newline_marked = old_newline_marked end end
def visit_if_node(node)
def visit_if_node(node) node.set_newline_flag(@newline_marked) super(node) end
def visit_statements_node(node)
def visit_statements_node(node) node.body.each do |child| child.set_newline_flag(@newline_marked) end super(node) end