diff options
author | Kevin Newton <kddnewton@gmail.com> | 2023-10-30 14:43:45 -0400 |
---|---|---|
committer | Kevin Newton <kddnewton@gmail.com> | 2023-11-01 13:10:29 -0400 |
commit | 79034fbd503769ed2742003e31920733e9300909 (patch) | |
tree | 3d2ec4007a132ed4a36ca3c30da7f31c6e1dda90 /lib/prism/parse_result/newlines.rb | |
parent | 953138698e4c2ba7a698ee133fbdc5d075556a5d (diff) | |
download | ruby-79034fbd503769ed2742003e31920733e9300909.tar.gz |
[ruby/prism] More Ruby docs
https://github.com/ruby/prism/commit/ca9a660f52
Diffstat (limited to 'lib/prism/parse_result/newlines.rb')
-rw-r--r-- | lib/prism/parse_result/newlines.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/prism/parse_result/newlines.rb b/lib/prism/parse_result/newlines.rb index 334f3f2a69..ca05f5b702 100644 --- a/lib/prism/parse_result/newlines.rb +++ b/lib/prism/parse_result/newlines.rb @@ -18,10 +18,12 @@ module Prism # MarkNewlinesVisitor, since that visitor is responsible for marking the # newlines for JRuby/TruffleRuby. class Newlines < Visitor + # Create a new Newlines visitor with the given newline offsets. def initialize(newline_marked) @newline_marked = newline_marked end + # Permit block/lambda nodes to mark newlines within themselves. def visit_block_node(node) old_newline_marked = @newline_marked @newline_marked = Array.new(old_newline_marked.size, false) @@ -35,6 +37,7 @@ module Prism alias_method :visit_lambda_node, :visit_block_node + # Mark if/unless nodes as newlines. def visit_if_node(node) node.set_newline_flag(@newline_marked) super(node) @@ -42,6 +45,7 @@ module Prism alias_method :visit_unless_node, :visit_if_node + # Permit statements lists to mark newlines within themselves. def visit_statements_node(node) node.body.each do |child| child.set_newline_flag(@newline_marked) |