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.
|
JSType |
getNamespaceOrTypedefType(String typeName)
Given the name of a namespace, returns its type.
|
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.
|
TypeI |
getTypeIOfThis()
Returns the expected type of
this in the current scope as a TypeI. |
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 |
isDeclaredInFunctionBlockOrParameter(String name)
Use only when in a function block scope and want to tell if a name is either at the top of the
function block scope or the function parameter scope
|
boolean |
isFunctionBlockScope() |
boolean |
isGlobal()
Returns whether this is the global scope.
|
boolean |
isLocal()
Returns whether this is a local scope (i.e.
|
getAllAccessibleVariables, isCatchScope, isFunctionScope, isHoistScopeRootNode, 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 final TypeI getTypeIOfThis()
StaticTypedScopethis in the current scope as a TypeI.getTypeIOfThis 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 Scopepublic boolean isDeclaredInFunctionBlockOrParameter(String name)
ScopeisDeclaredInFunctionBlockOrParameter 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 getNamespaceOrTypedefType(String typeName)
TypeIEnvgetNamespaceOrTypedefType in interface TypeIEnv<JSType>Copyright © 2009-2017 Google. All Rights Reserved.