Mutare.CallRouting.Call (mutare v0.4.1)

Copy Markdown View Source

Stable, resolved view of a known-macro call passed to routing and hosting callbacks.

arguments are the call's arguments, all of them, however the call was written: Mutare treats a piped routed call as the direct call Kernel.|>/2 would build, so (p in Post) |> from(order_by: …) is shown as from(p in Post, order_by: …). A classifier routes the piped operand as the first argument it is, and a host or mutator can read and rewrite it like any other. rebuild.(name, arguments) preserves the source's bare, qualified, or aliased call form; reports still show the pipe the user wrote.

At classification, arguments retain their written syntax. After routing, hosts see Elixir arguments resolved and :raw/:hosted fragments preserved, including their pipe operators.

The struct is produced by Mutare. Extension callbacks should match only the fields they need so additional fields can be added compatibly. To build one in a test, use new/4.

Summary

Functions

Build a call value from the written call node, the resolved module and name, and the rebuild function. arguments are read off node, so the two always agree.

Types

t()

@type t() :: %Mutare.CallRouting.Call{
  arguments: [Macro.t()],
  module: module() | atom() | nil,
  name: atom(),
  node: Macro.t(),
  rebuild: (atom(), [Macro.t()] -> Macro.t())
}

Functions

new(node, module, name, rebuild)

@spec new(Macro.t(), module() | atom() | nil, atom(), (atom(), [Macro.t()] ->
                                                   Macro.t())) :: t()

Build a call value from the written call node, the resolved module and name, and the rebuild function. arguments are read off node, so the two always agree.

iex> node = quote(do: where(Post, x > 1))
iex> call = Mutare.CallRouting.Call.new(node, Ecto.Query, :where,
...>   fn name, args -> {name, [], args} end)
iex> length(call.arguments)
2