Skip to main content

Module elixir

Module elixir 

Source
Expand description

Elixir: keyword Call identity (def, defmodule, quote, …), and applied versus named operators.

Structs§

ElixirRemoteCall
A recognized short-circuit Kernel call and the context its operands need.

Functions§

elixir_applying_operator
The binary_operator that applies op, an operator token, or None when the token is not applied there.
elixir_applying_remote_call
The Kernel remote call that applies op, a short-circuit operator’s name — the call elixir_kernel_short_circuit_name answers op for — with its argument list and ancestry, or None when op sits anywhere else. A token’s parents are the operator_identifier, then the dot, then the call; the identifier naming Kernel.and sits on the dot directly. Any other node fails on the first one or two parents’ kinds, so the check is cheap enough to ask of every identifier a walk meets.
elixir_call_keyword
Reads the text of the target field of an Elixir Call node.
elixir_do_block_call_children
Iterates the direct-child Call nodes inside the do_block of an Elixir Call (typically a defmodule). Used by Npm / Npa to scan a module body for method-defining macros / defstruct without descending into nested modules. Yields no items when the Call has no do_block.
elixir_is_class_macro
Class-defining macro (defmodule). Paired with elixir_is_method_macro where a caller needs both (“any space-opening declaration”).
elixir_is_inside_quote_block
Returns true when node is lexically nested inside the do_block of a quote do … end Call (Elixir’s metaprogramming template). A def / defp / defmacro / defmacrop inside quote does not define a method of any enclosing module — the syntax tree is a code template emitted later, when the surrounding macro is invoked. Treating those quoted Calls as methods inflates Wmc and disagrees with Npm’s direct-children classification (#310).
elixir_is_method_macro
Method-defining macros (def, defp, defmacro, defmacrop). The set is duplicated across checker, getter, and several metric impls because each consults it from a different trait surface; centralising the literal here keeps future additions (e.g. defguard) consistent.
elixir_kernel_short_circuit_name
The name of the short-circuit operator a remote call on Kernel with arguments applies, or None for any other node: the || of Kernel.||(a, b), or of x |> Kernel.||(y), which the pipe rewrites to it. Such a call expands the Kernel macro exactly as a || b does, so it short-circuits and decides as the operator does, where a capture (&Kernel.||/2, a call with no arguments) only names it. It has no binary_operator, so its operands are the call’s arguments, and under a pipe the piped value, rather than left / right fields.
elixir_short_circuit_kind
The short-circuit operation an operator token kind applies, keyed by its symbol: && for && and and, || for || and or. A word form demands a boolean left operand, but it is the same conjunction or disjunction to read, so one sequence key serves both spellings. None for any other kind.
elixir_short_circuit_name
elixir_short_circuit_kind for an operator’s name as elixir_kernel_short_circuit_name returns it: a token, or the identifier spelling Kernel.and / Kernel.or (#1582), whose bytes decide. Ask it only of such a name — an identifier is an and operator nowhere else.