Reach.AST (Reach v2.8.1)

Copy Markdown View Source

Shared helpers for working with Elixir AST.

Summary

Functions

Returns the module, function, and arguments represented by an Elixir call AST node.

Returns the name and arity represented by a function head.

Returns whether keyword AST contains a key.

Fetches a value from ordinary or Sourceror-wrapped keyword AST.

Returns a value from ordinary or Sourceror-wrapped keyword AST.

Returns a static module name represented by alias AST.

Returns real defmodule AST nodes from a quoted source tree.

Functions

call(arg1)

@spec call(Macro.t()) :: {module() | nil, atom(), [Macro.t()]} | nil

Returns the module, function, and arguments represented by an Elixir call AST node.

function_identity(arg1)

@spec function_identity(Macro.t()) :: {:ok, atom(), non_neg_integer()} | :error

Returns the name and arity represented by a function head.

keyword?(entries, key)

@spec keyword?(Macro.t(), atom()) :: boolean()

Returns whether keyword AST contains a key.

keyword_fetch(entries, key)

@spec keyword_fetch(Macro.t(), atom()) :: {:ok, Macro.t()} | :error

Fetches a value from ordinary or Sourceror-wrapped keyword AST.

keyword_value(entries, key)

@spec keyword_value(Macro.t(), atom()) :: Macro.t() | nil

Returns a value from ordinary or Sourceror-wrapped keyword AST.

module_name(arg1)

@spec module_name(Macro.t()) :: {:ok, module()} | :error

Returns a static module name represented by alias AST.

modules_in_file(ast)

Returns real defmodule AST nodes from a quoted source tree.