elvis_code (elvis_core v4.1.1)

View Source

Summary

Functions

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

Debugging utility function.

Debugging utility function.

Types

find_options/0

-type find_options() :: #{mode => node | zipper, traverse => content | all}.

Functions

code_zipper(Root)

-spec code_zipper(ktn_code:tree_node()) -> zipper:zipper(_).

code_zipper(Root, Mode)

-spec code_zipper(ktn_code:tree_node(), content | all) -> zipper:zipper(_).

find(Pred, Root)

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

find(Pred, Root, Opts)

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

find_by_location(Root, Location)

-spec find_by_location(ktn_code:tree_node(), {integer(), integer()}) ->
                          not_found | {ok, ktn_code:tree_node()}.

find_by_types(Types, Root)

find_by_types(Types, Root, Opts)

find_by_types_in_tokens(Types, Root)

find_token(Root, Location)

-spec find_token(ktn_code:tree_node(), {integer(), integer()}) -> not_found | {ok, map()}.