# `Juggernaut.Mutator.AST`
[🔗](https://github.com/holsee/juggernaut/blob/v0.4.0/lib/juggernaut/mutator/ast.ex#L1)

Helpers over Sourceror's AST (`docs/dependencies/sourceror.md`).

Sourceror wraps every literal in a one-element `:__block__` (`1` is
`{:__block__, [token: "1", ...], [1]}`); a two-element tuple is wrapped the same way.
These helpers build and read such literals, resolve aliases, compare nodes without
their metadata and render a node back to source.

# `alias_module`

```elixir
@spec alias_module(Macro.t(), %{required([atom()]) =&gt; module()}, module() | nil) ::
  {:ok, module()} | :error
```

The module an `__aliases__` node names, with the module's aliases expanded.

# `bare`

```elixir
@spec bare(Macro.t()) :: Macro.t()
```

`node` with all metadata removed, for structural comparison.

# `list_elements`

```elixir
@spec list_elements(Macro.t()) :: {:ok, [Macro.t()]} | :error
```

The elements of a list literal, or `:error`.

# `literal`

```elixir
@spec literal(term()) :: Macro.t()
```

A literal node, wrapped as Sourceror wraps literals.

# `literal?`

```elixir
@spec literal?(Macro.t(), (term() -&gt; boolean())) :: boolean()
```

Whether `node` is a wrapped literal for which `guard` holds.

# `literal_value`

```elixir
@spec literal_value(Macro.t()) :: {:ok, term()} | :error
```

The value of a wrapped literal, or `:error` for any other node.

# `named_var?`

```elixir
@spec named_var?(Macro.t()) :: boolean()
```

Whether `node` is a variable whose name does not start with `_`.

# `render`

```elixir
@spec render(Macro.t()) :: String.t()
```

Renders `node` to source with the Elixir formatter, without reading the project's
`.formatter.exs` and without comments.

# `same?`

```elixir
@spec same?(Macro.t(), Macro.t()) :: boolean()
```

Whether two nodes are equal apart from metadata.

# `strip_comments`

```elixir
@spec strip_comments(Macro.t()) :: Macro.t()
```

`node` without comment metadata, so rendering never re-emits comments.

# `tuple`

```elixir
@spec tuple([Macro.t()], keyword()) :: Macro.t()
```

A tuple node of `elements`, keeping the metadata of `original` when given.

# `tuple_elements`

```elixir
@spec tuple_elements(Macro.t()) :: {:ok, [Macro.t()]} | :error
```

The elements of a tuple literal (`{a, b}` or `{a, b, c}`), or `:error`.

# `var?`

```elixir
@spec var?(Macro.t()) :: boolean()
```

Whether `node` is a variable (any name, `_` included).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
