class SyntaxSuggest::CodeSearch

搜索代码中的语法错误

算法有三个主要阶段

  1. 净化/格式化输入源码

  2. 搜索无效代码块

  3. 将无效的代码块格式化为有意义的内容

此类负责这部分工作。

大部分繁重的工作都在

- CodeFrontier (Holds information for generating blocks and determining if we can stop searching)
- ParseBlocksFromLine (Creates blocks into the frontier)
- BlockExpand (Expands existing blocks to search more code)

## 语法错误检测

当 frontier 中包含语法错误时,我们可以停止搜索

search = CodeSearch.new(<<~EOM)
  def dog
    def lol
  end
EOM

search.call

search.invalid_blocks.map(&:to_s) # =>
# => ["def lol\n"]