Archeometer.Util.Code (Archeometer v0.5.0)
This module provides several helpers functions to deal with Elixir ASTs.
The functions have specific uses in other modules, but are general enough to be useful in other contexts.
Link to this section Summary
Functions
Create a new atom by concatenaing two other existing ones.
Walks the AST and finds all the definitions matching the given atoms, except if they are inside a macro definition, as quoted definitions are not yet instantiated.
Walks the given AST and stores all the ocurrences of the given atom as an operator.
Get declaration information from the AST of a def
-like macro. That is
usually the name and arguments, but it dependes on the exact construct.
Get the metadata of the given AST.
Get the maximum line number present in the metadata of an AST.
Determine the name of the module of some subset of the AST.
Determine the scope of the ast
inside the full_ast
.
Given a module name, it will return the underscored version of the last part of the module name.
Link to this section Functions
atom_concat(atom0, atom1)
Create a new atom by concatenaing two other existing ones.
collect_defs(full_ast, defatom)
Walks the AST and finds all the definitions matching the given atoms, except if they are inside a macro definition, as quoted definitions are not yet instantiated.
collect_nodes(ast, atoms)
Walks the given AST and stores all the ocurrences of the given atom as an operator.
get_decl(struct)
Get declaration information from the AST of a def
-like macro. That is
usually the name and arguments, but it dependes on the exact construct.
Current ones are def, defp, defmacro, defmacrop, defmodule, defstruct
.
get_meta(arg1, atom)
Get the metadata of the given AST.
num_lines(ast)
Get the maximum line number present in the metadata of an AST.
resolve_mod_name(full_ast, ast)
Determine the name of the module of some subset of the AST.
resolve_scope(full_ast, ast)
Determine the scope of the ast
inside the full_ast
.
snakefy(module)
Given a module name, it will return the underscored version of the last part of the module name.