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 value node is specified the predicate function receives a tree_node() as its argument. When zipper is specified the argument is the zipper location for the current node.
  • - traverse: the value content indicates to only take into account nodes in the parent-child hierarchy. When all is provided the nodes held in the node_attrs map are also taken into account in the search.
Link to this function

find_by_location(Root, Location)

View Source
-spec find_by_location(ktn_code:tree_node(), {integer(), integer()}) ->
                          not_found | {ok, ktn_code:tree_node()}.
Link to this function

find_token(Root, Location)

View Source
-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.

Link to this function

past_nesting_limit(Node, MaxLevel)

View Source
-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.