Spitfire.Env (spitfire v0.2.0)
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
ast()
@type ast() :: Macro.t()
Alias for Macro.t()
cursor_env()
@type cursor_env() :: env()
The environment at the cursor position
env()
@type env() :: %{ functions: [{module(), [func()]}], macros: [{module(), [macro()]}], attrs: [String.t()], variables: [atom()] }
The environment
final_env()
@type final_env() :: env()
The environment after expanding the entire syntax tree
func()
A name/arity pair
macro()
A name/arity pair
state()
The expansion state. Contains a total listing of local functions, macros, and module attributes.
Functions
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.