Building blocks shared by the operator families: operator swaps, table-driven call renames and literal replacements.
Summary
Functions
Whether op/arity at a site means Kernel's operator (the module does not define it).
The numeric literal replacements value + step, value - step and zero, without
duplicates or the value itself; variants zero, succ, pred. With negated? the
literal is the operand of a unary minus, so the variants name what happens to the
written value: -3 → -4 is pred.
A rename table of symmetric pairs: for each {modules, pairs} group, each name maps to
the other on every module listed.
Renames a resolved call per table: keys are {module, fun} (any arity) or
{module, fun, arity}, values the new function names. Arguments and the written form
are kept.
The sentinel string replacements use.
A sigil node with a delimiter that does not occur in content.
The content of a non-interpolated sigil, or :error.
A string literal node.
Swaps a binary operator for each operator table lists for it; the variant is the new
operator. Operators the module defines itself are left alone.
Functions
@spec kernel_op?(atom(), arity(), Juggernaut.Mutator.Context.t()) :: boolean()
Whether op/arity at a site means Kernel's operator (the module does not define it).
The numeric literal replacements value + step, value - step and zero, without
duplicates or the value itself; variants zero, succ, pred. With negated? the
literal is the operand of a unary minus, so the variants name what happens to the
written value: -3 → -4 is pred.
A rename table of symmetric pairs: for each {modules, pairs} group, each name maps to
the other on every module listed.
@spec rename(Macro.t(), Juggernaut.Mutator.Context.t(), map()) :: [{nil, Macro.t()}]
Renames a resolved call per table: keys are {module, fun} (any arity) or
{module, fun, arity}, values the new function names. Arguments and the written form
are kept.
@spec sentinel() :: String.t()
The sentinel string replacements use.
A sigil node with a delimiter that does not occur in content.
The content of a non-interpolated sigil, or :error.
A string literal node.
@spec swap(Macro.t(), Juggernaut.Mutator.Context.t(), %{required(atom()) => [atom()]}) :: [ {String.t(), Macro.t()} ]
Swaps a binary operator for each operator table lists for it; the variant is the new
operator. Operators the module defines itself are left alone.