1.0.0 • Published 10 years ago

ast-investigator v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

node-ast-investigator

Tools for JS AST analysis

ScopeChain

The main bread and butter of this library

require('ast-investigator').ScopeChain.fromString('x + y')

All of the properties are the operations within a specific scope not its children or parents. In order to determine if a reference/assignment is used outside / in children walk the chain.

String[] .init - names of parameters 
ASTNode? .node
ScopeChain? .parent
ScopeChain[] .children
<String, ASTNode[]> .assignments - Map of variable name to node that causes an assignmet
<String, ASTNode[]> .refs - Map of variable name to node that causes a reference **NOTE: this and assignments are separated**
<String, ASTNode[]> .vars - Map of variable name to declaration point(s)
ASTNode[] .calls 
ASTNode[] .throws
ASTNode[] .returns
ASTNode[] .breaks
ASTNode[] .evals
ASTNode[] .type - ScopeChain.SCOPE_TYPE {GLOBAL, WITH, FUNCTION, BLOCK, CATCH}