hank_utils (rebar3_hank v2.0.0)
View SourceUtility functions.
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 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/1's here, since we
don't really know what is the absolute path of the file referred by
the include directive.
Functions
-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.
-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.
Format rule result text for console output.
-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.
-spec macro_definition_name(erl_syntax:syntaxTree()) -> {string(), integer() | atom()}.
Get the macro definition name and arity of a given macro Node.
-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.
-spec node_has_atom(erl_syntax:syntaxTree(), atom()) -> boolean().
Returns true if the Node contains the Atom.
Only analyzes functions and attributes.
-spec node_has_attrs(erl_syntax:syntaxTree(), atom() | [atom()]) -> boolean().
Whether the given 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.
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/1's here, since we
don't really know what is the absolute path of the file referred by
the include directive.