View Source elvis_code (elvis_core v3.2.5)
Summary
Functions
Takes the root node of a parse_tree and returns name and arity of each exported function.
Same as calling find/3 with #{mode => node, traverse => content}
as the options map.
Find all nodes in the tree for which the predicate function returns true
. The options map has two keys
Takes the root node of a parse_tree and returns the name of each function, whether exported or not.
Takes the root node and returns the module's name.
Takes a node and returns all nodes where the nesting limit is exceeded.
Debugging utility function.
Types
-type find_options() :: #{mode => node | zipper, traverse => content | all}.
Functions
-spec code_zipper(ktn_code:tree_node()) -> zipper:zipper(_).
-spec code_zipper(ktn_code:tree_node(), content | all) -> zipper:zipper(_).
-spec exported_functions(ktn_code:tree_node()) -> [{atom(), integer()}].
Takes the root node of a parse_tree and returns name and arity of each exported function.
-spec exported_types(ktn_code:tree_node()) -> [{atom(), integer()}].
-spec find(fun((zipper:zipper(_)) -> boolean()), ktn_code:tree_node()) -> [ktn_code:tree_node()].
Same as calling find/3 with #{mode => node, traverse => content}
as the options map.
-spec find(fun((zipper:zipper(_)) -> boolean()), ktn_code:tree_node(), find_options()) -> [ktn_code:tree_node()].
Find all nodes in the tree for which the predicate function returns true
. The options map has two keys:
- -
mode
: when the valuenode
is specified the predicate function receives a tree_node() as its argument. Whenzipper
is specified the argument is the zipper location for the current node. - -
traverse
: the valuecontent
indicates to only take into account nodes in the parent-child hierarchy. Whenall
is provided the nodes held in thenode_attrs
map are also taken into account in the search.
-spec find_by_location(ktn_code:tree_node(), {integer(), integer()}) -> not_found | {ok, ktn_code:tree_node()}.
-spec find_token(ktn_code:tree_node(), {integer(), integer()}) -> not_found | {ok, map()}.
-spec function_names(ktn_code:tree_node()) -> [atom()].
Takes the root node of a parse_tree and returns the name of each function, whether exported or not.
-spec module_name(ktn_code:tree_node()) -> atom().
Takes the root node and returns the module's name.
-spec past_nesting_limit(ktn_code:tree_node(), integer()) -> [{ktn_code:tree_node(), integer()}].
Takes a node and returns all nodes where the nesting limit is exceeded.
-spec print_node(ktn_code:tree_node()) -> ok.
Debugging utility function.
-spec print_node(ktn_code:tree_node(), integer()) -> ok.