Class JSTypeExpression

java.lang.Object
com.google.javascript.rhino.JSTypeExpression
All Implemented Interfaces:
Serializable

public final class JSTypeExpression extends Object implements Serializable
When 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:
  • Constructor Details

    • JSTypeExpression

      public JSTypeExpression(Node root, String sourceName)
  • Method Details

    • replaceNamesWithUnknownType

      public JSTypeExpression replaceNamesWithUnknownType(Set<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<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()
      Does this expression denote an optional @param?
    • isVarArgs

      public boolean isVarArgs()
      Does this expression denote a rest args @param?
    • evaluate

      public JSType evaluate(@Nullable StaticTypedScope scope, JSTypeRegistry registry)
      Evaluates the type expression into a JSType object.
    • isEquivalentTo

      public boolean isEquivalentTo(@Nullable JSTypeExpression other)
      Does this object represent a type expression that is equivalent to the other one?
    • 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 String getSourceName()
    • toString

      public String toString()
      Overrides:
      toString in class 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<String> getRecordPropertyNames()
      Returns a set of keys of all record types (e.g. {{key : string }}) present in this JSTypeExpression.