View Source hank_utils (rebar3_hank v1.4.0)

Utility functions

Link to this section Summary

Functions

Returns a MFA tuple for given application node
Same as attr_args/3 but calling erl_syntax:concrete/1 for each element
Macro dodging version of erl_syntax:attribute_name/1
Format rule result text for console output
Get the function definition name and arity of a given Function Node.
Get the function name of a given Function Node.
Get the function definition tuple {name, arity} of a given Function Node.
Before OTP 23.2 test suites implemented an _implicit_ behavior. The only way to figure out that a module was actually a test suite was by its name.
Get the macro arity of given Node
Get the macro definition name and arity of a given Macro Node.
Generates a macro from the variable that's used in a control flow attribute. e.g. returns ?MACRO if it receives -ifdef(MACRO).
Get the parsed macro name of given Node
Returns true if the node contains the atom. Only analyzes functions and attributes.
Whether the given Node node has defined the given AttrNames attribute names or not
Returns the line number of the given node
Whether one of the given paths is contained inside the other one or not. It doesn't matter which one is contained at which other. Verifies if FilePath and IncludePath refer both to the same file. Note that we can't just compare both filename:absname's here, since we don't really know what is the absolute path of the file referred by the include directive.

Link to this section Functions

Link to this function

application_node_to_mfa(Node)

View Source
-spec application_node_to_mfa(erl_syntax:syntaxTree()) ->
                           undefined |
                           {unknown | string(), unknown | string(), [erl_syntax:syntaxTree()]} |
                           {string(), [erl_syntax:syntaxTree()]}.
Returns a MFA tuple for given application node
Link to this function

attr_args_concrete(AST, AttrName)

View Source
-spec attr_args_concrete(erl_syntax:forms(), atom() | [atom()]) -> [term()].
Same as attr_args/3 but calling erl_syntax:concrete/1 for each element
-spec attr_name(erl_syntax:syntaxTree()) -> atom() | string() | term().
Macro dodging version of erl_syntax:attribute_name/1
-spec format_text(string(), list()) -> binary().
Format rule result text for console output
Link to this function

function_description(Node)

View Source
-spec function_description(erl_syntax:syntaxTree()) -> string().
Get the function definition name and arity of a given Function Node.
-spec function_name(erl_syntax:syntaxTree()) -> string().
Get the function name of a given Function Node.
-spec function_tuple(erl_syntax:syntaxTree()) -> {atom(), pos_integer()}.
Get the function definition tuple {name, arity} of a given Function Node.
-spec is_old_test_suite(file:filename()) -> boolean().
Before OTP 23.2 test suites implemented an _implicit_ behavior. The only way to figure out that a module was actually a test suite was by its name.
-spec macro_arity(erl_syntax:syntaxTree()) -> none | pos_integer().
Get the macro arity of given Node
Link to this function

macro_definition_name(Node)

View Source
-spec macro_definition_name(erl_syntax:syntaxTree()) -> {string(), integer() | atom()}.
Get the macro definition name and arity of a given Macro Node.
Link to this function

macro_from_control_flow_attr(Node)

View Source
-spec macro_from_control_flow_attr(erl_syntax:syntaxTree()) -> erl_syntax:syntaxTree().
Generates a macro from the variable that's used in a control flow attribute. e.g. returns ?MACRO if it receives -ifdef(MACRO).
-spec macro_name(erl_syntax:syntaxTree()) -> unknown | string().
Get the parsed macro name of given Node
Link to this function

node_has_atom(Node, Atom)

View Source
-spec node_has_atom(erl_syntax:syntaxTree(), atom()) -> boolean().
Returns true if the node contains the atom. Only analyzes functions and attributes.
Link to this function

node_has_attrs(Node, AttrName)

View Source
-spec node_has_attrs(erl_syntax:syntaxTree(), atom() | [atom()]) -> boolean().
Whether the given Node node has defined the given AttrNames attribute names or not
-spec node_line(erl_syntax:syntaxTree()) -> non_neg_integer() | {non_neg_integer(), pos_integer()}.
Returns the line number of the given node
Link to this function

paths_match(IncludePath, _)

View Source
-spec paths_match(string(), string()) -> boolean().
Whether one of the given paths is contained inside the other one or not. It doesn't matter which one is contained at which other. Verifies if FilePath and IncludePath refer both to the same file. Note that we can't just compare both filename:absname's here, since we don't really know what is the absolute path of the file referred by the include directive.