class SyntacticScopeCreator 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 implementation is not thread-safe.
Modifier and Type | Class and Description |
---|---|
(package private) static class |
SyntacticScopeCreator.DefaultRedeclarationHandler
The default handler for duplicate declarations.
|
(package private) static interface |
SyntacticScopeCreator.RedeclarationHandler
Interface for injectable duplicate handling.
|
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
ARGUMENTS |
private AbstractCompiler |
compiler |
private InputId |
inputId |
private boolean |
isTyped |
private SyntacticScopeCreator.RedeclarationHandler |
redeclarationHandler |
private Scope |
scope |
Modifier | Constructor and Description |
---|---|
private |
SyntacticScopeCreator(AbstractCompiler compiler,
boolean isTyped) |
private |
SyntacticScopeCreator(AbstractCompiler compiler,
SyntacticScopeCreator.RedeclarationHandler redeclarationHandler) |
Modifier and Type | Method and Description |
---|---|
<T extends Scope> |
createScope(Node n,
T parent)
Creates a
Scope object. |
private void |
declareVar(Node n)
Declares a variable.
|
boolean |
hasBlockScope() |
(package private) static SyntacticScopeCreator |
makeTyped(AbstractCompiler compiler) |
(package private) static SyntacticScopeCreator |
makeUntyped(AbstractCompiler compiler) |
(package private) static SyntacticScopeCreator |
makeUntypedWithRedeclHandler(AbstractCompiler compiler,
SyntacticScopeCreator.RedeclarationHandler redeclarationHandler) |
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
private final boolean isTyped
private SyntacticScopeCreator(AbstractCompiler compiler, SyntacticScopeCreator.RedeclarationHandler redeclarationHandler)
private SyntacticScopeCreator(AbstractCompiler compiler, boolean isTyped)
static SyntacticScopeCreator makeUntyped(AbstractCompiler compiler)
static SyntacticScopeCreator makeTyped(AbstractCompiler compiler)
static SyntacticScopeCreator makeUntypedWithRedeclHandler(AbstractCompiler compiler, SyntacticScopeCreator.RedeclarationHandler redeclarationHandler)
public <T extends Scope> T createScope(Node n, T 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)
n
- The node corresponding to the variable name.public boolean hasBlockScope()
hasBlockScope
in interface ScopeCreator