public abstract class JSType extends Object implements FunctionTypeI, ObjectTypeI
| Modifier and Type | Field and Description |
|---|---|
static JSType |
BOOLEAN |
protected static int |
BOOLEAN_MASK |
static JSType |
BOTTOM |
protected static int |
BOTTOM_MASK |
protected static int |
END_MASK |
protected static int |
ENUM_MASK |
protected static int |
FALSE_MASK |
static JSType |
FALSE_TYPE |
static JSType |
FALSY |
protected static int |
FALSY_MASK |
static boolean |
mockToString |
protected static int |
NON_SCALAR_MASK |
static JSType |
NULL |
protected static int |
NULL_MASK |
static JSType |
NULL_OR_UNDEF |
static JSType |
NUM_OR_STR |
static JSType |
NUMBER |
protected static int |
NUMBER_MASK |
static JSType |
STRING |
protected static int |
STRING_MASK |
static JSType |
TOP |
static JSType |
TOP_DICT |
protected static int |
TOP_MASK |
static JSType |
TOP_OBJECT |
static JSType |
TOP_SCALAR |
protected static int |
TOP_SCALAR_MASK |
static JSType |
TOP_STRUCT |
protected static int |
TRUE_MASK |
static JSType |
TRUE_TYPE |
static JSType |
TRUTHY |
protected static int |
TRUTHY_MASK |
protected static int |
TYPEVAR_MASK |
static JSType |
UNDEFINED |
protected static int |
UNDEFINED_MASK |
static JSType |
UNKNOWN |
protected static int |
UNKNOWN_MASK |
| Constructor and Description |
|---|
JSType() |
| Modifier and Type | Method and Description |
|---|---|
StringBuilder |
appendTo(StringBuilder builder) |
JSType |
autobox() |
JSType |
autoboxAndGetObject() |
boolean |
containsArray() |
TypeI |
convertMethodToFunction()
Creates a new function type B based on the original function type A.
|
boolean |
equals(Object o) |
JSType |
findSubtypeWithProp(QualifiedName pname) |
static JSType |
fromObjectType(com.google.javascript.jscomp.newtypes.ObjectType obj) |
static JSType |
fromTypeVar(String typevarName) |
FunctionTypeI |
getConstructor()
Gets this object's constructor, or null if it is a native
object (constructed natively vs.
|
JSType |
getDeclaredProp(QualifiedName qname) |
String |
getDisplayName() |
JSType |
getEnumeratedType() |
protected abstract com.google.common.collect.ImmutableSet<EnumType> |
getEnums() |
FunctionType |
getFunType() |
FunctionType |
getFunTypeIfSingletonObj() |
JSType |
getIndexedType() |
JSType |
getIndexType() |
ObjectTypeI |
getInstanceType() |
JSDocInfo |
getJSDocInfo() |
JSType |
getLowestSupertypeWithProperty(String propertyName,
boolean isOverride) |
protected abstract int |
getMask() |
NominalType |
getNominalTypeIfSingletonObj() |
Node |
getOwnPropertyDefsite(String propertyName) |
JSDocInfo |
getOwnPropertyJSDocInfo(String propertyName) |
JSType |
getProp(QualifiedName qname) |
Node |
getPropertyDefsite(String propertyName) |
JSType |
getPrototypeObject() |
String |
getReferenceName() |
TypeI |
getReturnType() |
Node |
getSource()
Gets the AST Node where this function was defined.
|
List<? extends FunctionTypeI> |
getSubTypes()
Returns a list of types that are subtypes of this type.
|
TypeI |
getTypeOfThis()
Gets the type of
this in this function. |
protected abstract String |
getTypeVar() |
boolean |
hasConstantProp(QualifiedName pname) |
int |
hashCode() |
boolean |
hasNonScalar() |
boolean |
hasProp(QualifiedName qname) |
boolean |
hasProperties() |
boolean |
hasProperty(String propertyName) |
boolean |
hasTypeVariable() |
static boolean |
haveCommonSubtype(JSType lhs,
JSType rhs) |
boolean |
isAnyFalsyType() |
boolean |
isAnyTruthyType() |
boolean |
isBoolean() |
boolean |
isBottom() |
boolean |
isConstructor() |
boolean |
isDict() |
boolean |
isEnumElement() |
boolean |
isEquivalentTo(TypeI type) |
boolean |
isFalseOrFalsy() |
boolean |
isFunctionType() |
boolean |
isFunctionWithProperties() |
boolean |
isInstanceofObject() |
boolean |
isInstanceType()
Whether this type is an instance object of some constructor.
|
boolean |
isInterface() |
boolean |
isInterfaceDefinition() |
boolean |
isInterfaceInstance() |
boolean |
isLoose() |
boolean |
isNamespace() |
boolean |
isNonClassyObject() |
boolean |
isNonLooseSubtypeOf(JSType other) |
boolean |
isNullable() |
boolean |
isNullOrUndef() |
boolean |
isNumber() |
boolean |
isOriginalConstructor() |
boolean |
isPrototypeObject() |
boolean |
isScalar() |
boolean |
isSingletonObj() |
boolean |
isString() |
boolean |
isStruct() |
boolean |
isSubtypeOf(TypeI other) |
boolean |
isTop() |
boolean |
isTrueOrTruthy() |
boolean |
isTypeVariable() |
boolean |
isUndefined() |
boolean |
isUnion() |
boolean |
isUnknown() |
boolean |
isUnknownType() |
static JSType |
join(JSType lhs,
JSType rhs) |
boolean |
mayBeDict() |
boolean |
mayBeStruct() |
boolean |
mayHaveProp(QualifiedName qname) |
static JSType |
meet(JSType lhs,
JSType rhs) |
JSType |
negate() |
static JSType |
plus(JSType lhs,
JSType rhs) |
JSType |
removeType(JSType other) |
TypeI |
restrictByNotNullOrUndefined()
If this is a union type, returns a union type that does not include
the null or undefined type.
|
static void |
setCommonTypes(JSTypes commonTypes) |
void |
setSource(Node n) |
JSType |
specialize(JSType other) |
JSType |
substituteGenerics(Map<String,JSType> concreteTypes) |
JSType |
substituteGenericsWithUnknown() |
JSType |
toBoolean() |
FunctionTypeI |
toMaybeFunctionType()
Downcasts this to a FunctionTypeI, or returns null if this is not
a function.
|
ObjectTypeI |
toMaybeObjectType()
If this type is a single object, downcast it to ObjectTypeI.
|
String |
toString() |
boolean |
unifyWith(JSType other,
List<String> typeParameters,
com.google.common.collect.Multimap<String,JSType> typeMultimap)
Unify
this, which may contain free type variables,
with other, a concrete subtype, modifying the supplied
typeMultimap to add any new template variable type bindings. |
static MismatchInfo |
whyNotSubtypeOf(JSType t1,
JSType t2) |
JSType |
withDeclaredProperty(QualifiedName qname,
JSType type,
boolean isConstant) |
JSType |
withFunction(FunctionType ft,
NominalType fnNominal) |
JSType |
withLoose()
Turns the class-less object of this type (if any) into a loose object
|
JSType |
withoutProperty(QualifiedName qname) |
JSType |
withProperty(QualifiedName qname,
JSType type) |
JSType |
withPropertyRequired(String pname) |
protected static final int BOTTOM_MASK
protected static final int TYPEVAR_MASK
protected static final int NON_SCALAR_MASK
protected static final int ENUM_MASK
protected static final int TRUE_MASK
protected static final int FALSE_MASK
protected static final int NULL_MASK
protected static final int NUMBER_MASK
protected static final int STRING_MASK
protected static final int UNDEFINED_MASK
protected static final int END_MASK
protected static final int TRUTHY_MASK
protected static final int FALSY_MASK
protected static final int UNKNOWN_MASK
protected static final int TOP_MASK
protected static final int BOOLEAN_MASK
protected static final int TOP_SCALAR_MASK
public static boolean mockToString
public static final JSType BOOLEAN
public static final JSType BOTTOM
public static final JSType FALSE_TYPE
public static final JSType FALSY
public static final JSType NULL
public static final JSType NUMBER
public static final JSType STRING
public static final JSType TOP
public static final JSType TOP_SCALAR
public static final JSType TRUE_TYPE
public static final JSType TRUTHY
public static final JSType UNDEFINED
public static final JSType UNKNOWN
public static final JSType TOP_OBJECT
public static final JSType TOP_STRUCT
public static final JSType TOP_DICT
public static final JSType NULL_OR_UNDEF
public static final JSType NUM_OR_STR
protected abstract int getMask()
protected abstract String getTypeVar()
protected abstract com.google.common.collect.ImmutableSet<EnumType> getEnums()
public static JSType fromObjectType(com.google.javascript.jscomp.newtypes.ObjectType obj)
public boolean isTop()
public boolean isUndefined()
public boolean isUnknown()
public boolean isTrueOrTruthy()
public boolean isFalseOrFalsy()
public boolean isAnyTruthyType()
public boolean isAnyFalsyType()
public boolean isBoolean()
public boolean isString()
public boolean isNumber()
public boolean isNullOrUndef()
public boolean isScalar()
public static void setCommonTypes(JSTypes commonTypes)
public boolean hasNonScalar()
public boolean isNullable()
isNullable in interface TypeIpublic boolean isTypeVariable()
public boolean hasTypeVariable()
public boolean isStruct()
public boolean mayBeStruct()
public boolean isLoose()
public boolean isDict()
public JSType getIndexType()
public JSType getIndexedType()
public boolean mayBeDict()
public boolean isEnumElement()
public boolean isUnion()
public boolean isFunctionWithProperties()
public boolean isNamespace()
public JSType getEnumeratedType()
public JSType autobox()
public JSType substituteGenericsWithUnknown()
public boolean unifyWith(JSType other, List<String> typeParameters, com.google.common.collect.Multimap<String,JSType> typeMultimap)
this, which may contain free type variables,
with other, a concrete subtype, modifying the supplied
typeMultimap to add any new template variable type bindings.
Note that if this is a union type, some of the union members may
be ignored if they are not present in other.public JSType negate()
public JSType toBoolean()
public boolean isNonLooseSubtypeOf(JSType other)
public boolean isSubtypeOf(TypeI other)
isSubtypeOf in interface TypeIpublic static MismatchInfo whyNotSubtypeOf(JSType t1, JSType t2)
public JSType withFunction(FunctionType ft, NominalType fnNominal)
public boolean isSingletonObj()
public FunctionType getFunTypeIfSingletonObj()
public FunctionType getFunType()
public NominalType getNominalTypeIfSingletonObj()
public boolean isInterfaceInstance()
public boolean isNonClassyObject()
public boolean isInterfaceDefinition()
public JSType withLoose()
public JSType getProp(QualifiedName qname)
public JSType getDeclaredProp(QualifiedName qname)
public boolean mayHaveProp(QualifiedName qname)
public boolean hasProp(QualifiedName qname)
public boolean hasConstantProp(QualifiedName pname)
public boolean containsArray()
containsArray in interface TypeIpublic JSType withoutProperty(QualifiedName qname)
public JSType withProperty(QualifiedName qname, JSType type)
public JSType withDeclaredProperty(QualifiedName qname, JSType type, boolean isConstant)
public JSType findSubtypeWithProp(QualifiedName pname)
public StringBuilder appendTo(StringBuilder builder)
public boolean isConstructor()
isConstructor in interface TypeIpublic boolean isOriginalConstructor()
isOriginalConstructor in interface TypeIpublic boolean isEquivalentTo(TypeI type)
isEquivalentTo in interface TypeIpublic boolean isFunctionType()
isFunctionType in interface TypeIpublic boolean isInterface()
isInterface in interface TypeIpublic boolean isUnknownType()
isUnknownType in interface TypeIpublic TypeI restrictByNotNullOrUndefined()
TypeIrestrictByNotNullOrUndefined in interface TypeIpublic FunctionTypeI toMaybeFunctionType()
TypeItoMaybeFunctionType in interface TypeIpublic ObjectTypeI toMaybeObjectType()
TypeItoMaybeObjectType in interface TypeIpublic JSType autoboxAndGetObject()
autoboxAndGetObject in interface TypeIpublic String getDisplayName()
getDisplayName in interface TypeIpublic TypeI convertMethodToFunction()
FunctionTypeIconvertMethodToFunction in interface FunctionTypeIpublic ObjectTypeI getInstanceType()
getInstanceType in interface FunctionTypeIpublic String getReferenceName()
getReferenceName in interface FunctionTypeIpublic Node getSource()
FunctionTypeIgetSource in interface FunctionTypeIpublic List<? extends FunctionTypeI> getSubTypes()
FunctionTypeIgetSubTypes in interface FunctionTypeIpublic TypeI getTypeOfThis()
FunctionTypeIthis in this function.getTypeOfThis in interface FunctionTypeIpublic boolean hasProperties()
hasProperties in interface FunctionTypeIpublic void setSource(Node n)
setSource in interface FunctionTypeIpublic TypeI getReturnType()
getReturnType in interface FunctionTypeIpublic FunctionTypeI getConstructor()
ObjectTypeIgetConstructor in interface ObjectTypeIpublic JSType getPrototypeObject()
getPrototypeObject in interface ObjectTypeIpublic JSDocInfo getJSDocInfo()
getJSDocInfo in interface TypeIpublic JSDocInfo getOwnPropertyJSDocInfo(String propertyName)
getOwnPropertyJSDocInfo in interface ObjectTypeIpublic Node getOwnPropertyDefsite(String propertyName)
getOwnPropertyDefsite in interface ObjectTypeIpublic Node getPropertyDefsite(String propertyName)
getPropertyDefsite in interface ObjectTypeIpublic JSType getLowestSupertypeWithProperty(String propertyName, boolean isOverride)
getLowestSupertypeWithProperty in interface ObjectTypeIpublic boolean isPrototypeObject()
isPrototypeObject in interface TypeIpublic boolean isInstanceofObject()
isInstanceofObject in interface TypeIpublic boolean isInstanceType()
ObjectTypeIisInstanceType in interface ObjectTypeIpublic boolean hasProperty(String propertyName)
hasProperty in interface ObjectTypeICopyright © 2009-2016 Google. All Rights Reserved.