Credo.Code.Module (Credo v1.7.12)

View Source

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

location()

@type location() :: [line: pos_integer(), column: pos_integer()]

module_part()

@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

aliases(ast)

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

analyze(ast)

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

attribute(ast, attr_name)

Reads an attribute from a module's ast

def_arity(ast)

Returns the arity of the given function definition ast

def_count(ast)

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

def_name(arg1)

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

def_name_with_op(ast)

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

def_name_with_op(ast, arity)

def_names(ast)

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

def_names_with_op(ast)

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

def_names_with_op(ast, arity)

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

defs(ast)

exception?(arg1)

modules(ast)

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

name(ast)

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