View Source Igniter.Code.Function (igniter v0.3.2)
Utilities for working with functions.
Summary
Functions
Appends an argument to a function call, leaving the zipper at the function call's node.
Returns true
if the argument at the provided index exists and matches the provided pattern
Returns true if the argument at the given index matches the provided predicate
Returns true
if the node is a function call
Returns true
if the node is a function call of the given name
Returns true
if the node is a function call of the given name and arity
Moves to a function call by the given name and arity, matching the given predicate, in the current or lower scope
Moves to a function call by the given name and arity, matching the given predicate, in the current scope
Moves to the nth
argument of a function call.
Updates the nth
argument of a function call, leaving the zipper at the function call's node.
Functions
@spec append_argument(Sourceror.Zipper.t(), any()) :: {:ok, Sourceror.Zipper.t()} | :error
Appends an argument to a function call, leaving the zipper at the function call's node.
Returns true
if the argument at the provided index exists and matches the provided pattern
@spec argument_matches_predicate?( Sourceror.Zipper.t(), non_neg_integer(), (Sourceror.Zipper.t() -> boolean()) ) :: boolean()
Returns true if the argument at the given index matches the provided predicate
@spec function_call?(Sourceror.Zipper.t()) :: boolean()
Returns true
if the node is a function call
@spec function_call?(Sourceror.Zipper.t(), atom()) :: boolean()
Returns true
if the node is a function call of the given name
@spec function_call?(Sourceror.Zipper.t(), atom(), non_neg_integer()) :: boolean()
Returns true
if the node is a function call of the given name and arity
@spec move_to_def( Sourceror.Zipper.t(), fun :: atom(), arity :: integer() | [integer()] ) :: {:ok, Sourceror.Zipper.t()} | :error
@spec move_to_defp( Sourceror.Zipper.t(), fun :: atom(), arity :: integer() | [integer()] ) :: {:ok, Sourceror.Zipper.t()} | :error
move_to_function_call(zipper, name, arity, predicate \\ fn _ -> true end)
View SourceMoves to a function call by the given name and arity, matching the given predicate, in the current or lower scope
move_to_function_call_in_current_scope(zipper, name, arity, predicate \\ fn _ -> true end)
View SourceMoves to a function call by the given name and arity, matching the given predicate, in the current scope
@spec move_to_nth_argument( Sourceror.Zipper.t(), non_neg_integer() ) :: {:ok, Sourceror.Zipper.t()} | :error
Moves to the nth
argument of a function call.
@spec update_nth_argument( Sourceror.Zipper.t(), non_neg_integer(), (Sourceror.Zipper.t() -> {:ok, Sourceror.Zipper.t()} | :error) ) :: {:ok, Sourceror.Zipper.t()} | :error
Updates the nth
argument of a function call, leaving the zipper at the function call's node.