Class JSTypeExpression

  • All Implemented Interfaces:
    java.io.Serializable

    public final class JSTypeExpression
    extends java.lang.Object
    implements java.io.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:
    Serialized Form
    • 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.
      • 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 java.lang.String getSourceName()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • 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.