Package com.google.javascript.rhino
Class JSTypeExpression
- java.lang.Object
-
- com.google.javascript.rhino.JSTypeExpression
-
- All Implemented Interfaces:
java.io.Serializable
public final class JSTypeExpression extends java.lang.Object implements java.io.SerializableWhen parsing a jsdoc, a type-annotation string is parsed to a type AST. Somewhat confusingly, we use the Node class both for type ASTs and for the source-code AST. JSTypeExpression wraps a type AST. During type checking, type ASTs are evaluated to JavaScript types.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description JSTypeExpression(Node root, java.lang.String sourceName)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description JSTypeExpressioncopy()booleanequals(java.lang.Object other)JSTypeevaluate(StaticTypedScope scope, JSTypeRegistry registry)Evaluates the type expression into aJSTypeobject.com.google.common.collect.ImmutableSet<java.lang.String>getAllTypeNames()Returns a set of all string names in this type expressioncom.google.common.collect.ImmutableList<Node>getAllTypeNodes()Returns a list of all type nodes in this type expression.com.google.common.collect.ImmutableSet<java.lang.String>getRecordPropertyNames()Returns a set of keys of all record types (e.g.NodegetRoot()java.lang.StringgetSourceName()inthashCode()booleanisExplicitUnknownTemplateBound()Whether this expression is an explicit unknown template bound.booleanisOptionalArg()booleanisVarArgs()static JSTypeExpressionmakeOptionalArg(JSTypeExpression expr)Make the given type expression into an optional type expression, if possible.JSTypeExpressionreplaceNamesWithUnknownType(java.util.Set<java.lang.String> names)Replaces given names in this type expression with unknownjava.lang.StringtoString()
-
-
-
Constructor Detail
-
JSTypeExpression
public JSTypeExpression(Node root, java.lang.String sourceName)
-
-
Method Detail
-
replaceNamesWithUnknownType
public JSTypeExpression replaceNamesWithUnknownType(java.util.Set<java.lang.String> names)
Replaces given names in this type expression with unknown
-
getAllTypeNodes
public com.google.common.collect.ImmutableList<Node> getAllTypeNodes()
Returns a list of all type nodes in this type expression.
-
getAllTypeNames
public com.google.common.collect.ImmutableSet<java.lang.String> getAllTypeNames()
Returns a set of all string names in this type expression
-
makeOptionalArg
public static JSTypeExpression makeOptionalArg(JSTypeExpression expr)
Make the given type expression into an optional type expression, if possible.
-
isOptionalArg
public boolean isOptionalArg()
- Returns:
- Whether this expression denotes an optional
@param.
-
isVarArgs
public boolean isVarArgs()
- Returns:
- Whether this expression denotes a rest args
@param.
-
evaluate
public JSType evaluate(StaticTypedScope scope, JSTypeRegistry registry)
Evaluates the type expression into aJSTypeobject.
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getRoot
public Node getRoot()
- Returns:
- The source for this type expression. Note that it will not contain an expression if there's an @override tag.
-
getSourceName
public java.lang.String getSourceName()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
copy
public JSTypeExpression copy()
-
isExplicitUnknownTemplateBound
public boolean isExplicitUnknownTemplateBound()
Whether this expression is an explicit unknown template bound.
-
getRecordPropertyNames
public com.google.common.collect.ImmutableSet<java.lang.String> getRecordPropertyNames()
Returns a set of keys of all record types (e.g. {{key : string }}) present in this JSTypeExpression.
-
-