class SyntaxSuggest::Visitor

Walks the Prism AST to extract structural info that cannot be reliably determined from tokens alone.

Such as the location of lines that must be logically joined so the search algorithm will treat them as one. Example:

source = <<~RUBY
  User                        # 1
    .where(name: "Earlopain") # 2
    .first                    # 3
RUBY
ast, _tokens = Prism.parse_lex(source).value
visitor = Visitor.new
visitor.visit(ast)
visitor.consecutive_lines # => Set[2, 1]

This output means that line 1 and line 2 need to be joined with their next line.

And determining the location of โ€œendlessโ€ method definitions. For example:

source = <<~RUBY
  def cube(x)
    x * x * x
  end
  def square(x) = x * x # 1
RUBY

ast, _tokens = Prism.parse_lex(source).value
visitor = Visitor.new
visitor.visit(ast)
visitor.endless_def_keyword_offsets # => Set[28]