View Source Igniter.Code.List (igniter v0.4.0)

Utilities for working with lists.

Summary

Functions

Appends quoted to the list unless it is already present, determined by equality_pred.

Appends quoted to the list

Moves to the list item matching the given predicate, assuming you are currently inside the list

Finds the index of the first list item that satisfies pred

Returns true if the zipper is at a list literal

Moves to the list item matching the given predicate

Moves to the list item matching the given predicate

Prepends quoted to the list unless it is already present, determined by equality_pred.

Prepends quoted to the list

Removes the item at the given index, returning :error if nothing is at that index

Types

@type equality_pred() :: (Sourceror.Zipper.t(), Macro.t() -> boolean())

Functions

Link to this function

append_new_to_list(zipper, quoted, equality_pred \\ &Common.nodes_equal?/2)

View Source
@spec append_new_to_list(Sourceror.Zipper.t(), quoted :: Macro.t(), equality_pred()) ::
  {:ok, Sourceror.Zipper.t()} | :error

Appends quoted to the list unless it is already present, determined by equality_pred.

Link to this function

append_to_list(zipper, quoted)

View Source
@spec append_to_list(Sourceror.Zipper.t(), quoted :: Macro.t()) ::
  {:ok, Sourceror.Zipper.t()} | :error

Appends quoted to the list

Link to this function

do_move_to_list_item(zipper, pred)

View Source

Moves to the list item matching the given predicate, assuming you are currently inside the list

Link to this function

find_list_item_index(zipper, pred)

View Source
@spec find_list_item_index(Sourceror.Zipper.t(), (Sourceror.Zipper.t() -> boolean())) ::
  integer() | nil

Finds the index of the first list item that satisfies pred

@spec list?(Sourceror.Zipper.t()) :: boolean()

Returns true if the zipper is at a list literal

@spec map(Sourceror.Zipper.t(), (Sourceror.Zipper.t() -> {:ok, Sourceror.Zipper.t()})) ::
  {:ok, Sourceror.Zipper.t()} | :error

Moves to the list item matching the given predicate

Link to this function

move_to_list_item(zipper, pred)

View Source
@spec move_to_list_item(Sourceror.Zipper.t(), (Sourceror.Zipper.t() -> boolean())) ::
  {:ok, Sourceror.Zipper.t()} | :error

Moves to the list item matching the given predicate

Link to this function

prepend_new_to_list(zipper, quoted, equality_pred \\ &Common.nodes_equal?/2)

View Source
@spec prepend_new_to_list(Sourceror.Zipper.t(), quoted :: Macro.t(), equality_pred()) ::
  {:ok, Sourceror.Zipper.t()} | :error

Prepends quoted to the list unless it is already present, determined by equality_pred.

Link to this function

prepend_to_list(zipper, quoted)

View Source
@spec prepend_to_list(Sourceror.Zipper.t(), quoted :: Macro.t()) ::
  {:ok, Sourceror.Zipper.t()} | :error

Prepends quoted to the list

Link to this function

remove_from_list(zipper, predicate)

View Source
@spec remove_from_list(
  Sourceror.Zipper.t(),
  predicate :: (Sourceror.Zipper.t() -> boolean())
) ::
  {:ok, Sourceror.Zipper.t()} | :error
Link to this function

remove_index(zipper, index)

View Source
@spec remove_index(Sourceror.Zipper.t(), index :: non_neg_integer()) ::
  {:ok, Sourceror.Zipper.t()} | :error

Removes the item at the given index, returning :error if nothing is at that index

Link to this function

replace_in_list(zipper, predicate, value)

View Source
@spec replace_in_list(
  Sourceror.Zipper.t(),
  predicate :: (Sourceror.Zipper.t() -> boolean()),
  term :: any()
) :: {:ok, Sourceror.Zipper.t()} | :error