Skip to main content

elixir_applying_operator

Function elixir_applying_operator 

Source
pub fn elixir_applying_operator<'a>(
    op: &Node<'a>,
    ancestors: Ancestors<'a, '_>,
) -> Option<Node<'a>>
Expand description

The binary_operator that applies op, an operator token, or None when the token is not applied there.

An operator token also names the operator: &==/2, &and/2 and Kernel.||(a, b) hold it inside an operator_identifier, and the single-token atom / keyword spell it too. None of those is a binary_operator with operands to compare or chain, and under error recovery the parent can be an ERROR with no operands, so every decision metric keys on this parent rather than on the token (#1531, #1534). A remote call that names the operator still applies it, though; see elixir_applying_remote_call.

Matched by rule name rather than by kind_id: the grammar aliases binary_operator to three ids (Elixir::BinaryOperator through BinaryOperator3), and a name comparison stays correct when a bump adds a fourth (grammar-dispatch ยง1).