Package com.google.javascript.jscomp
Class Scope.Var
- java.lang.Object
-
- com.google.javascript.jscomp.Scope.Var
-
- All Implemented Interfaces:
StaticReference<JSType>
,StaticSlot<JSType>
- Direct Known Subclasses:
Scope.Arguments
- Enclosing class:
- Scope
public static class Scope.Var extends java.lang.Object implements StaticSlot<JSType>, StaticReference<JSType>
Stores info about a variable
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object other)
Scope.Var
getDeclaration()
Gets the declaration of this symbol.Node
getInitialValue()
java.lang.String
getInputName()
JSDocInfo
getJSDocInfo()
Gets the JSDocInfo for the variable.java.lang.String
getName()
Gets the name of the variable.Node
getNameNode()
Returns the name node that produced this variable.Node
getNode()
Gets the node for the name of the variable.Node
getParentNode()
Gets the parent of the name node.StaticSourceFile
getSourceFile()
The source file where the reference lives.Scope.Var
getSymbol()
The variable that this reference points to.JSType
getType()
Gets this variable's type.int
hashCode()
boolean
isBleedingFunction()
Whether this is a bleeding function (an anonymous named function that bleeds into the inner scope).boolean
isConst()
Returnstrue
if the variable is declared as a constant, based on the value reported byNodeUtil
.boolean
isDefine()
Returnstrue
if the variable is declared as a define.boolean
isGlobal()
Returns whether this is a global variable.boolean
isLocal()
Returns whether this is a local variable.boolean
isNoShadow()
boolean
isTypeInferred()
Returns whether this variable's type is inferred.java.lang.String
toString()
-
-
-
Method Detail
-
getName
public java.lang.String getName()
Gets the name of the variable.- Specified by:
getName
in interfaceStaticSlot<JSType>
-
getNode
public Node getNode()
Gets the node for the name of the variable.- Specified by:
getNode
in interfaceStaticReference<JSType>
-
getSourceFile
public StaticSourceFile getSourceFile()
Description copied from interface:StaticReference
The source file where the reference lives.- Specified by:
getSourceFile
in interfaceStaticReference<JSType>
-
getSymbol
public Scope.Var getSymbol()
Description copied from interface:StaticReference
The variable that this reference points to.- Specified by:
getSymbol
in interfaceStaticReference<JSType>
-
getDeclaration
public Scope.Var getDeclaration()
Description copied from interface:StaticSlot
Gets the declaration of this symbol. May not exist.- Specified by:
getDeclaration
in interfaceStaticSlot<JSType>
-
getParentNode
public Node getParentNode()
Gets the parent of the name node.
-
isBleedingFunction
public boolean isBleedingFunction()
Whether this is a bleeding function (an anonymous named function that bleeds into the inner scope).
-
isGlobal
public boolean isGlobal()
Returns whether this is a global variable.
-
isLocal
public boolean isLocal()
Returns whether this is a local variable.
-
isConst
public boolean isConst()
Returnstrue
if the variable is declared as a constant, based on the value reported byNodeUtil
.
-
isDefine
public boolean isDefine()
Returnstrue
if the variable is declared as a define. A variable is a define if it is annotated by@define
.
-
getInitialValue
public Node getInitialValue()
-
getType
public JSType getType()
Gets this variable's type. To know whether this type has been inferred, see#isTypeInferred()
.- Specified by:
getType
in interfaceStaticSlot<JSType>
- Returns:
- The type or
null
if no type is declared for it.
-
getNameNode
public Node getNameNode()
Returns the name node that produced this variable.
-
getJSDocInfo
public JSDocInfo getJSDocInfo()
Gets the JSDocInfo for the variable.- Specified by:
getJSDocInfo
in interfaceStaticSlot<JSType>
-
isTypeInferred
public boolean isTypeInferred()
Returns whether this variable's type is inferred. To get the variable's type, seegetType()
.- Specified by:
isTypeInferred
in interfaceStaticSlot<JSType>
-
getInputName
public java.lang.String getInputName()
-
isNoShadow
public boolean isNoShadow()
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-