public class TypedScope extends java.lang.Object implements StaticTypedScope
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 |
|---|---|
java.lang.Iterable<V> |
getAllAccessibleVariables()
Return an iterable over all of the variables accessible to this scope (i.e.
|
java.lang.Iterable<V> |
getAllSymbols() |
V |
getArgumentsVar()
Get a unique Var object to represent "arguments" within this scope
|
S |
getClosestContainerScope()
Returns the closest container scope.
|
java.lang.Iterable<TypedVar> |
getDeclarativelyUnboundVarsWithoutTypes()
Returns the variables in this scope that have been declared with 'var' and not declared with a
known type.
|
int |
getDepth()
The depth of the scope.
|
JSDocInfo |
getJsdocOfTypeDeclaration(java.lang.String typeName) |
JSType |
getNamespaceOrTypedefType(java.lang.String typeName) |
V |
getOwnSlot(java.lang.String name)
Like
getSlot but does not recurse into parent scopes. |
TypedScope |
getParent()
Returns the parent scope, or null if this is the global scope.
|
S |
getParentScope()
Returns the scope enclosing this one or null if none.
|
Node |
getRootNode()
Gets the container node of the scope.
|
V |
getSlot(java.lang.String name)
Returns any defined slot within this scope for this name.
|
JSType |
getTypeOfThis()
Gets the type of
this in the current scope. |
V |
getVar(java.lang.String name)
Returns the variable, may be null
|
int |
getVarCount()
Returns number of variables in this scope (excluding the special 'arguments' variable)
|
java.lang.Iterable<V> |
getVarIterable()
Return an iterable over all of the variables declared in this scope
(except the special 'arguments' variable).
|
boolean |
hasOwnSlot(java.lang.String name)
Returns true if a variable is declared in this scope, with no recursion.
|
boolean |
hasSlot(java.lang.String name)
Returns true if a variable is declared in this or any parent scope.
|
boolean |
isBlockScope() |
boolean |
isCatchScope() |
boolean |
isFunctionBlockScope() |
boolean |
isFunctionScope() |
boolean |
isGlobal()
Returns whether this is the global scope.
|
boolean |
isLocal()
Returns whether this is a local scope (i.e.
|
boolean |
isModuleScope() |
java.lang.String |
toString() |
TypedScope |
typed() |
Scope |
untyped() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetOwnSlot, getParentScope, getSlotgetRootNodepublic TypedScope typed()
public int getDepth()
public TypedScope getParent()
public JSType getTypeOfThis()
this in the current scope.getTypeOfThis in interface StaticTypedScopepublic java.lang.Iterable<TypedVar> getDeclarativelyUnboundVarsWithoutTypes()
public JSType getNamespaceOrTypedefType(java.lang.String typeName)
public JSDocInfo getJsdocOfTypeDeclaration(java.lang.String typeName)
public final java.lang.String toString()
toString in class java.lang.Objectpublic Scope untyped()
public Node getRootNode()
getRootNode in interface StaticScopepublic final S getParentScope()
StaticScopegetParentScope in interface StaticScopepublic final V getSlot(java.lang.String name)
StaticScopegetSlot in interface StaticScopename - The name of the variable slot to look up.null if no
definition exists.public final V getOwnSlot(java.lang.String name)
StaticScopegetSlot but does not recurse into parent scopes.getOwnSlot in interface StaticScopepublic V getVar(java.lang.String name)
public final V getArgumentsVar()
public final boolean hasOwnSlot(java.lang.String name)
public final boolean hasSlot(java.lang.String name)
public java.lang.Iterable<V> getVarIterable()
public final java.lang.Iterable<V> getAllAccessibleVariables()
The iterable contains variables from inner scopes before adding variables from outer parent scopes.
We do not include the special 'arguments' variable.
public java.lang.Iterable<V> getAllSymbols()
public int getVarCount()
public boolean isGlobal()
public boolean isLocal()
public final boolean isBlockScope()
public final boolean isFunctionBlockScope()
public final boolean isFunctionScope()
public final boolean isModuleScope()
public final boolean isCatchScope()
public final S getClosestContainerScope()
Copyright © 2009-2018 Google. All Rights Reserved.