Spitfire.Env (spitfire v0.1.0)

Environment querying

Summary

Functions

Expands the environment of the given AST.

Functions

Link to this function

expand(ast, file)

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

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.