类 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