Spitfire.Env (spitfire v0.1.5)

Environment querying

Summary

Types

Alias for Macro.t()

The environment at the cursor position

The environment

The environment after expanding the entire syntax tree

A name/arity pair

A name/arity pair

The expansion state. Contains a total listing of local functions, macros, and module attributes.

Functions

Expands the environment of the given AST.

Types

@type ast() :: Macro.t()

Alias for Macro.t()

Link to this type

cursor_env()

@type cursor_env() :: env()

The environment at the cursor position

@type env() :: %{
  functions: [{module(), [func()]}],
  macros: [{module(), [macro()]}],
  attrs: [String.t()],
  variables: [atom()]
}

The environment

@type final_env() :: env()

The environment after expanding the entire syntax tree

@type func() :: {atom(), arity()}

A name/arity pair

@type macro() :: {atom(), arity()}

A name/arity pair

@type state() :: %{functions: [func()], macros: [macro()], attrs: [String.t()]}

The expansion state. Contains a total listing of local functions, macros, and module attributes.

Functions

Link to this function

expand(ast, file)

@spec expand(Macro.t(), String.t()) ::
  {ast :: ast(), final_state :: state(), final_env :: final_env(),
   cursor_env :: cursor_env()}

Expands the environment of the given AST.

In order to get the environment at the given cursor position, expand/2 expects to find a __cursor__() node inside the AST to indicate where the cursor is.

This can be achieved by passing your code fragment (meaning, a string of your code from the top to where the cursor is) to Spitfire.container_cursor_to_quoted/1, and then passing that to expand/2.

Please see the tests for example usage.