類別 SyntaxSuggest::UnvisitedLines

追蹤哪些行已擴充至各種程式碼區塊,以及哪些行仍未探索

公開類別方法

new(code_lines:) 按一下以切換來源
# File lib/syntax_suggest/unvisited_lines.rb, line 7
def initialize(code_lines:)
  @unvisited = code_lines.sort_by(&:indent_index)
  @visited_lines = {}
  @visited_lines.compare_by_identity
end

公開實例方法

empty?() 按一下以切換來源
# File lib/syntax_suggest/unvisited_lines.rb, line 13
def empty?
  @unvisited.empty?
end
peek() 按一下以切換來源
# File lib/syntax_suggest/unvisited_lines.rb, line 17
def peek
  @unvisited.last
end
pop() 按一下以切換來源
# File lib/syntax_suggest/unvisited_lines.rb, line 21
def pop
  @unvisited.pop
end
visit_block(block) 按一下以切換來源
# File lib/syntax_suggest/unvisited_lines.rb, line 25
def visit_block(block)
  block.lines.each do |line|
    next if @visited_lines[line]
    @visited_lines[line] = true
  end

  while @visited_lines[@unvisited.last]
    @unvisited.pop
  end
end