End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
SyntaxSuggest::ParseBlocksFromIndentLine#each_neighbor_block
each_neighbor_block(target_line) { |block| ... }
lib/syntax_suggest/parse_blocks_from_indent_line.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.2.0/lib/syntax_suggest/parse_blocks_from_indent_line.rb, line 37
def each_neighbor_block(target_line)
scan = AroundBlockScan.new(code_lines: code_lines, block: CodeBlock.new(lines: target_line))
.skip(:empty?)
.skip(:hidden?)
.scan_while { |line| line.indent >= target_line.indent }
neighbors = scan.code_block.lines
block = CodeBlock.new(lines: neighbors)
if neighbors.length <= 2 || block.valid?
yield block
else
until neighbors.empty?
lines = [neighbors.pop]
while (block = CodeBlock.new(lines: lines)) && block.invalid? && neighbors.any?
lines.prepend neighbors.pop
end
yield block if block
end
end
end
Builds blocks from bottom up