View Source merlin_lib (merlin v3.0.1)
Helpers for working with erl_syntax:syntaxTree()
.
erl_syntax_lib
, but with a different set of helpers, and a preference for returning maps over proplists.
Summary
Functions
Returns the first Node
that satisfies the given function, or {error, notfound}
if no such Node
is found.
Return the first Node
that satisfies the given function, or {error, notfound}
if no such form is found.
true
if the given syntax node is a erl_syntax
node, false
otherwise.Result
, while preserving any errors and/or warnings.Updates the given node using the given groups or subtrees of another node.
Returns the value of the given literal node as an Erlang term.
Types
-type predicate() :: predicate(merlin:ast()).
-type predicate(T) :: fun((T) -> boolean()).
Functions
-spec deep_find_by(merlin:ast() | [merlin:ast()], predicate()) -> {ok, merlin:ast()} | {error, notfound}.
Returns the first Node
that satisfies the given function, or {error, notfound}
if no such Node
is found.
-spec find_by([merlin:ast()], predicate(Node)) -> {ok, Node} | {error, notfound} when Node :: merlin:ast().
Return the first Node
that satisfies the given function, or {error, notfound}
if no such form is found.
See also: deep_find_by/2.
-spec flatten(NodeOrNodes) -> [merlin:ast()] when NodeOrNodes :: merlin:ast() | [NodeOrNodes].
-spec is_erl_syntax(merlin:erl_syntax_ast()) -> true; (merlin:erl_parse()) -> false.
true
if the given syntax node is a erl_syntax
node, false
otherwise.
-spec then(Result, fun((Forms) -> Forms)) -> Result when Result :: merlin:parse_transform_return(Forms), Forms :: [merlin:ast()].
Result
, while preserving any errors and/or warnings.
-spec update_tree(merlin:ast(), [[merlin:ast()]] | merlin:ast()) -> merlin:ast().
Updates the given node using the given groups or subtrees of another node.
This is a generalisation oferl_syntax:update_tree/2
.
-spec value(merlin:ast()) -> term().
Returns the value of the given literal node as an Erlang term.
Raises{badvalue, Node}
if the given Node
is not an literal node.