public class TypedScope extends Scope implements StaticTypedScope<JSType>, TypeIEnv<JSType>
TypedScope is also used as a lattice element for flow-sensitive type inference.
As a lattice element, a scope is viewed as a map from names to types. A name
not in the map is considered to have the bottom type. The join of two maps m1
and m2 is the map of the union of names with JSType.getLeastSupertype(com.google.javascript.rhino.jstype.JSType)
to meet the m1 type and m2 type.
| Modifier and Type | Method and Description |
|---|---|
Iterable<TypedVar> |
getAllSymbols() |
Var |
getArgumentsVar()
Get a unique VAR object to represents "arguments" within this scope
|
Scope |
getClosestHoistScope()
If a var were declared in this scope, return the scope it would be hoisted to.
|
Iterable<TypedVar> |
getDeclarativelyUnboundVarsWithoutTypes() |
int |
getDepth()
The depth of the scope.
|
JSDocInfo |
getJsdocOfTypeDeclaration(String typeName)
Returns the jsdoc at the definition site of the type represented by typeName.
|
TypedVar |
getOwnSlot(String name)
Like
getSlot but does not recurse into parent scopes. |
TypedScope |
getParent() |
StaticTypedScope<JSType> |
getParentScope()
Returns the scope enclosing this one or null if none.
|
Node |
getRootNode()
Gets the container node of the scope.
|
TypedVar |
getSlot(String name)
Returns any defined slot within this scope for this name.
|
JSType |
getType(String typeName)
Returns the type represented by typeName
|
JSType |
getTypeOfThis()
Gets the type of
this in the current scope. |
TypedVar |
getVar(String name)
Returns the variable, may be null
|
int |
getVarCount()
Returns number of variables in this scope (excluding the special 'arguments' variable)
|
Iterable<TypedVar> |
getVarIterable()
Return an iterable over all of the variables declared in this scope
(except the special 'arguments' variable).
|
boolean |
isBlockScope() |
boolean |
isDeclared(String name,
boolean recurse)
Returns true if a variable is declared.
|
boolean |
isDeclaredSloppy(String name,
boolean recurse)
Deprecated.
use #isDeclared instead
|
boolean |
isFunctionBlockScope() |
boolean |
isGlobal()
Returns whether this is the global scope.
|
boolean |
isLocal()
Returns whether this is a local scope (i.e.
|
isCatchScope, isFunctionScope, isModuleScope, toStringpublic int getDepth()
Scopepublic Node getRootNode()
ScopegetRootNode in interface StaticScopegetRootNode in class Scopepublic TypedScope getParent()
public StaticTypedScope<JSType> getParentScope()
StaticScopegetParentScope in interface StaticTypedScope<JSType>getParentScope in interface StaticScopegetParentScope in class Scopepublic JSType getTypeOfThis()
this in the current scope.getTypeOfThis in interface StaticTypedScope<JSType>public TypedVar getSlot(String name)
StaticScopegetSlot in interface StaticTypedScope<JSType>getSlot in interface StaticScopegetSlot in class Scopename - The name of the variable slot to look up.null if no
definition exists.public TypedVar getOwnSlot(String name)
StaticScopegetSlot but does not recurse into parent scopes.getOwnSlot in interface StaticTypedScope<JSType>getOwnSlot in interface StaticScopegetOwnSlot in class Scopepublic TypedVar getVar(String name)
Scopepublic Var getArgumentsVar()
ScopegetArgumentsVar in class Scope@Deprecated public boolean isDeclaredSloppy(String name, boolean recurse)
isDeclaredSloppy in class Scopepublic boolean isDeclared(String name, boolean recurse)
ScopeisDeclared in class Scopepublic Iterable<TypedVar> getVarIterable()
ScopegetVarIterable in class Scopepublic Iterable<TypedVar> getAllSymbols()
getAllSymbols in class Scopepublic int getVarCount()
ScopegetVarCount in class Scopepublic boolean isGlobal()
Scopepublic boolean isLocal()
Scopepublic Iterable<TypedVar> getDeclarativelyUnboundVarsWithoutTypes()
public boolean isBlockScope()
isBlockScope in class Scopepublic boolean isFunctionBlockScope()
isFunctionBlockScope in class Scopepublic Scope getClosestHoistScope()
ScopegetClosestHoistScope in class Scopepublic JSType getType(String typeName)
TypeIEnvCopyright © 2009-2017 Google. All Rights Reserved.