mv — reorder a logical definition within a single file.
Moves a def (with its attached @spec/@doc/leading comments and
every clause — i.e. the whole Adze.Definition group) to just before
another def in the same module.
Scope:
- Single file, single module. Both
--definitionand--beforemust resolve to defs in the samedefmodule. Cross-module moves are explicitly out of scope — that'sextract's job. --beforeis the only supported anchor (no--after).mv/2is pure (returns the diff + new source).mv!/2writes the file.
Usage
iex> Adze.Move.mv(source, definition: "bar/2", before: "baz/1")
{:ok, %{diff: "...", new_source: "..."}}
Adze.Move.mv!("lib/foo.ex", definition: "bar/2", before: "baz/1")
# → {:ok, %{diff: ..., new_source: ...}} + rewrites lib/foo.ex
Summary
Types
@type opts() :: [ definition: Adze.Definition.definition_spec(), before: Adze.Definition.definition_spec(), include_attrs: [atom()] ]