# `Igniter.Code.Module`
[🔗](https://github.com/ash-project/igniter/blob/v0.8.3/lib/igniter/code/module.ex#L5)

Utilities for working with Elixir modules

# `create_module`

> This function is deprecated. Use `Igniter.Project.Module.create_module/4` instead.

Creates a new file & module in its appropriate location.

# `find_all_matching_modules`

> This function is deprecated. Use `Igniter.Project.Module.find_all_matching_modules/2` instead.

```elixir
@spec find_all_matching_modules(igniter :: Igniter.t(), (module(),
                                                   Sourceror.Zipper.t() -&gt;
                                                     boolean())) ::
  {Igniter.t(), [module()]}
```

# `find_and_update_module`

> This function is deprecated. Use `Igniter.Project.Module.find_and_update_module/3` instead.

```elixir
@spec find_and_update_module(Igniter.t(), module(), (Sourceror.Zipper.t() -&gt;
                                                 {:ok, Sourceror.Zipper.t()}
                                                 | :error)) ::
  {:ok, Igniter.t()} | {:error, Igniter.t()}
```

Finds a module and updates its contents. Returns `{:error, igniter}` if the module could not be found. Do not discard this igniter.

# `find_and_update_module!`

> This function is deprecated. Use `Igniter.Project.Module.find_and_update_module!/3` instead.

# `find_and_update_or_create_module`

> This function is deprecated. Use `Igniter.Project.Module.find_and_update_or_create_module/5` instead.

Finds a module and updates its contents wherever it is.

If the module does not yet exist, it is created with the provided contents. In that case,
the path is determined with `Igniter.Code.Module.proper_location/2`, but may optionally be overwritten with options below.

# Options

- `:path` - Path where to create the module, relative to the project root. Default: `nil` (uses `:kind` to determine the path).

# `find_module`

> This function is deprecated. Use `Igniter.Project.Module.find_module/2` instead.

```elixir
@spec find_module(Igniter.t(), module()) ::
  {:ok, {Igniter.t(), Rewrite.Source.t(), Sourceror.Zipper.t()}}
  | {:error, Igniter.t()}
```

Finds a module, returning a new igniter, and the source and zipper location. This new igniter should not be discarded.

In general, you should not use the returned source and zipper to update the module, instead, use this to interrogate
the contents or source in some way, and then call `find_and_update_module/3` with a function to perform an update.

# `find_module!`

> This function is deprecated. Use `Igniter.Project.Module.find_module!/2` instead.

```elixir
@spec find_module!(Igniter.t(), module()) ::
  {Igniter.t(), Rewrite.Source.t(), Sourceror.Zipper.t()} | no_return()
```

Finds a module, raising an error if its not found.

See `find_module/2` for more information.

# `module?`

# `module_exists?`

> This function is deprecated. Use `Igniter.Project.Module.module_exists/2` instead.

Checks if a module is defined somewhere in the project. The returned igniter should not be discarded.

# `module_matching?`

Checks if the value is a module that matches a given predicate

# `module_name`

> This function is deprecated. Use `module_name/2` instead..

```elixir
@spec module_name(String.t()) :: module()
```

Given a suffix, returns a module name with the prefix of the current project.

# `module_name`

> This function is deprecated. Use `Igniter.Project.Module.module_name/2` instead..

```elixir
@spec module_name(Igniter.t(), String.t()) :: module()
```

Given a suffix, returns a module name with the prefix of the current project.

# `module_name_prefix`

> This function is deprecated. Use `Igniter.Project.Module.module_name_prefix/1` instead.

```elixir
@spec module_name_prefix() :: module()
```

The module name prefix based on the mix project's module name

# `module_name_prefix`

> This function is deprecated. Use `Igniter.Project.Module.module_name_prefix/1` instead.

```elixir
@spec module_name_prefix(Igniter.t()) :: module()
```

The module name prefix based on the mix project's module name

# `move_to_attribute_definition`

```elixir
@spec move_to_attribute_definition(Sourceror.Zipper.t(), atom()) ::
  {:ok, Sourceror.Zipper.t()} | :error
```

Move to an attribute definition inside a module.

## Example

Given this module:

    defmodule MyAppWeb.Endpoint do
      @doc "My App Endpoint"

      @session_options [
        store: :cookie,
        ...
      ]
    end

You can move into `@doc` attribute with:

    Igniter.Code.Module.move_to_attribute_definition(zipper, :doc)

Or you can move into `@session_options` constant with:

    Igniter.Code.Module.move_to_attribute_definition(zipper, :session_options)

# `move_to_def`

> This function is deprecated. Use `Igniter.Code.Function.move_to_def/3` instead.

# `move_to_defmodule`

```elixir
@spec move_to_defmodule(Sourceror.Zipper.t()) :: {:ok, Sourceror.Zipper.t()} | :error
```

Moves the zipper to a defmodule call

# `move_to_defmodule`

```elixir
@spec move_to_defmodule(Sourceror.Zipper.t(), module()) ::
  {:ok, Sourceror.Zipper.t()} | :error
```

Moves the zipper to a specific defmodule call

# `move_to_defp`

> This function is deprecated. Use `Igniter.Code.Function.move_to_defp/3` instead.

# `move_to_module_using`

```elixir
@spec move_to_module_using(Sourceror.Zipper.t(), module() | [module()]) ::
  {:ok, Sourceror.Zipper.t()} | :error
```

Moves the zipper to the body of a module that `use`s the provided module (or one of the provided modules).

# `move_to_use`

Moves the zipper to the `use` statement for a provided module.

# `move_to_using`

> This function is deprecated. Use `move_to_use/2` instead..

# `parse`

> This function is deprecated. Use `Igniter.Project.Module.parse/1` instead..

```elixir
@spec parse(String.t()) :: module()
```

Parses a string into a module name

# `proper_location`

> This function is deprecated. Use `Igniter.Project.Module.proper_location/3`.

```elixir
@spec proper_location(module(), source_folder :: String.t()) :: Path.t()
```

Returns the idiomatic file location for a given module, starting with "lib/".

# `proper_test_location`

> This function is deprecated. Use `Igniter.Project.Module.proper_location/3`.

```elixir
@spec proper_test_location(module()) :: Path.t()
```

Returns the test file location for a given module, according to
`mix test` expectations, starting with "test/" and ending with "_test.exs".

# `proper_test_support_location`

> This function is deprecated. Use `Igniter.Project.Module.proper_location/3`.

```elixir
@spec proper_test_support_location(module()) :: Path.t()
```

Returns the test support location for a given module, starting with
"test/support/" and dropping the module name prefix in the path.

---

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