class SyntaxTree::Parser

def on_binary(left, operator, right)

Experimental RBS support (using type sampling data from the type_fusion project).

def on_binary: ((SyntaxTree::VarRef | SyntaxTree::CallNode) left, Symbol operator, (SyntaxTree::VarRef | SyntaxTree::Int | SyntaxTree::SymbolLiteral) right) -> untyped

This signature was generated using 3 samples from 1 application.

) -> Binary
untyped right
(Op | Symbol) operator,
untyped left,
on_binary: (
:call-seq:
def on_binary(left, operator, right)
  if operator.is_a?(Symbol)
    # Here, we're going to search backward for the token that's between the
    # two operands that matches the operator so we can delete it from the
    # list.
    range = (left.location.end_char + 1)...right.location.start_char
    index =
      tokens.rindex do |token|
        token.is_a?(Op) && token.name == operator &&
          range.cover?(token.location.start_char)
      end
    tokens.delete_at(index) if index
  else
    # On most Ruby implementations, operator is a Symbol that represents
    # that operation being performed. For instance in the example `1 < 2`,
    # the `operator` object would be `:<`. However, on JRuby, it's an `@op`
    # node, so here we're going to explicitly convert it into the same
    # normalized form.
    operator = tokens.delete(operator).value
  end
  Binary.new(
    left: left,
    operator: operator,
    right: right,
    location: left.location.to(right.location)
  )
end