class Es6SyntacticScopeCreator extends java.lang.Object implements ScopeCreator
The syntactic scope creator scans the parse tree to create a Scope object containing all the variable declarations in that scope. This class adds supported for block-level scopes introduced in ECMAScript 6.
This implementation is not thread-safe.
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
ARGUMENTS |
private AbstractCompiler |
compiler |
private InputId |
inputId |
private SyntacticScopeCreator.RedeclarationHandler |
redeclarationHandler |
private Scope |
scope |
Constructor and Description |
---|
Es6SyntacticScopeCreator(AbstractCompiler compiler) |
Es6SyntacticScopeCreator(AbstractCompiler compiler,
SyntacticScopeCreator.RedeclarationHandler redeclarationHandler) |
Modifier and Type | Method and Description |
---|---|
Scope |
createScope(Node n,
Scope parent)
Creates a
Scope object. |
private void |
declareLHS(Scope declarationScope,
Node lhs) |
private void |
declareVar(Node n) |
private void |
declareVar(Scope s,
Node n)
Declares a variable.
|
boolean |
hasBlockScope() |
private boolean |
isNodeAtCurrentLexicalScope(Node n)
Determines whether the name should be declared at current lexical scope.
|
private void |
scanRoot(Node n) |
private void |
scanVars(Node n)
Scans and gather variables declarations under a Node
|
private final AbstractCompiler compiler
private Scope scope
private InputId inputId
private final SyntacticScopeCreator.RedeclarationHandler redeclarationHandler
private static final java.lang.String ARGUMENTS
Es6SyntacticScopeCreator(AbstractCompiler compiler)
Es6SyntacticScopeCreator(AbstractCompiler compiler, SyntacticScopeCreator.RedeclarationHandler redeclarationHandler)
public Scope createScope(Node n, Scope parent)
ScopeCreator
Scope
object.createScope
in interface ScopeCreator
n
- the root node (either a FUNCTION node, a SCRIPT node, or a
synthetic block node whose children are all SCRIPT nodes)parent
- the parent Scope object (may be null)private void scanRoot(Node n)
private void scanVars(Node n)
private void declareVar(Node n)
private void declareVar(Scope s, Node n)
s
- The scope to declare the variable in.n
- The node corresponding to the variable name.private boolean isNodeAtCurrentLexicalScope(Node n)
n
- The declaration node to be checkedpublic boolean hasBlockScope()
hasBlockScope
in interface ScopeCreator