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

Finds the modules of a parsed file and what the walk needs to know about each one:
its aliases, imports, local functions, whether it is a `GenServer`, its function
clauses in source order, the module-body expressions that run at compile time, and its
`context`: every module-body expression other than a function clause, a nested module
or a documentation attribute (what a function's behaviour may depend on besides its
own clauses: `use`, `import`, `alias`, attributes, `defstruct`), which
`Juggernaut.Cache.Footprint` hashes with each function.

A nested `defmodule` is a module of its own, named inside its parent. `defimpl` is
named `Protocol.Target`. Clause indices count every `def`, `defp`, `defmacro` and
`defmacrop` of one name and arity in source order, bodiless heads included
(design notes §6).

# `clause`

```elixir
@type clause() :: %{
  module: module(),
  kind: atom(),
  name: atom(),
  arity: arity(),
  index: non_neg_integer(),
  node: Macro.t(),
  impl?: boolean(),
  bodiless?: boolean(),
  first_line: pos_integer(),
  last_line: pos_integer()
}
```

# `info`

```elixir
@type info() :: %{
  module: module(),
  aliases: %{required([atom()]) =&gt; module()},
  imports: [module()],
  locals: MapSet.t({atom(), arity()}),
  genserver?: boolean(),
  clauses: [clause()],
  compile_time: [Macro.t()],
  context: [Macro.t()]
}
```

# `head_call`

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

The name and arguments of a clause head (`f(a)`, `f(a) when g`), or `:error`.

# `modules`

```elixir
@spec modules(Macro.t()) :: [info()]
```

The modules defined in `ast`, outermost first, in source order.

---

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