View Source Credo.Code.Module (Credo v1.7.7-rc.0)

This module provides helper functions to analyse modules, return the defined functions or module attributes.

Summary

Functions

Returns the list of aliases defined in a given module source code.

Reads an attribute from a module's ast

Returns the arity of the given function definition ast

Returns the function/macro count for the given module's AST

Returns the name of the function/macro defined in the given ast

Returns the {fun_name, op} tuple of the function/macro defined in the given ast

Returns the name of the functions/macros for the given module's ast

Returns the name of the functions/macros for the given module's ast

Returns the name of the functions/macros for the given module's ast if it has the given arity.

Returns the list of modules used in a given module source code.

Returns the name of a module's given ast node.

Types

@type location() :: [line: pos_integer(), column: pos_integer()]
@type module_part() ::
  :moduledoc
  | :shortdoc
  | :behaviour
  | :use
  | :import
  | :alias
  | :require
  | :module_attribute
  | :defstruct
  | :opaque
  | :type
  | :typep
  | :callback
  | :macrocallback
  | :optional_callbacks
  | :public_fun
  | :private_fun
  | :public_macro
  | :private_macro
  | :public_guard
  | :private_guard
  | :callback_fun
  | :callback_macro
  | :module

Functions

Returns the list of aliases defined in a given module source code.

@spec analyze(Macro.t()) :: [{module(), [{module_part(), location()}]}]
Link to this function

attribute(ast, attr_name)

View Source

Reads an attribute from a module's ast

Returns the arity of the given function definition ast

Returns the function/macro count for the given module's AST

Returns the name of the function/macro defined in the given ast

Returns the {fun_name, op} tuple of the function/macro defined in the given ast

Link to this function

def_name_with_op(ast, arity)

View Source

Returns the name of the functions/macros for the given module's ast

Returns the name of the functions/macros for the given module's ast

Link to this function

def_names_with_op(ast, arity)

View Source

Returns the name of the functions/macros for the given module's ast if it has the given arity.

Returns the list of modules used in a given module source code.

Returns the name of a module's given ast node.