public abstract class JSType extends Object implements TypeI, FunctionTypeI, ObjectTypeI
| Modifier and Type | Field and Description |
|---|---|
static boolean |
mockToString |
protected static int |
NON_SCALAR_MASK |
protected static int |
NULL_MASK |
protected static int |
TYPEVAR_MASK |
| Modifier and Type | Method and Description |
|---|---|
boolean |
acceptsArguments(List<? extends TypeI> argumentTypes)
Checks if a call to this function with the given list of arguments is valid.
|
StringBuilder |
appendTo(StringBuilder builder) |
JSType |
autobox() |
ObjectTypeI |
autoboxAndGetObject() |
boolean |
containsArray() |
TypeI |
convertMethodToFunction()
Creates a new function type B based on the original function type A.
|
static String |
createGetterPropName(String originalPropName) |
static String |
createSetterPropName(String originalPropName) |
boolean |
equals(Object o) |
JSType |
findSubtypeWithProp(QualifiedName pname) |
static JSType |
fromObjectType(com.google.javascript.jscomp.newtypes.ObjectType obj) |
static JSType |
fromTypeVar(JSTypes commonTypes,
String typevarName) |
Collection<ObjectTypeI> |
getAncestorInterfaces() |
FunctionTypeI |
getConstructor()
Gets this object's constructor, or null if it is a native
object (constructed natively vs.
|
JSType |
getDeclaredProp(QualifiedName qname) |
Collection<JSType> |
getDirectImplementors() |
String |
getDisplayName() |
JSType |
getEnumeratedTypeOfEnumElement() |
protected abstract com.google.common.collect.ImmutableSet<EnumType> |
getEnums() |
FunctionType |
getFunType() |
FunctionType |
getFunTypeIfSingletonObj() |
TypeI |
getGreatestSubtypeWithProperty(String pname) |
JSType |
getIndexedType() |
JSType |
getIndexType() |
ObjectTypeI |
getInstanceType() |
JSDocInfo |
getJSDocInfo() |
TypeI |
getLegacyResolvedType()
Only called on instances of NamedType.
|
protected abstract int |
getMask() |
NominalType |
getNominalTypeIfSingletonObj() |
FunctionTypeI |
getOwnerFunction() |
Node |
getOwnPropertyDefSite(String propertyName) |
JSDocInfo |
getOwnPropertyJSDocInfo(String propertyName) |
Iterable<String> |
getOwnPropertyNames()
Returns the names of all the properties directly on this type.
|
JSType |
getProp(QualifiedName qname) |
Node |
getPropertyDefSite(String propertyName) |
JSDocInfo |
getPropertyJSDocInfo(String propertyName) |
JSType |
getPrototypeObject()
Returns the __proto__ object of this object type, NOT the ".prototype" property.
|
ObjectTypeI |
getPrototypeProperty() |
ObjectTypeI |
getRawType() |
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.
|
FunctionTypeI |
getSuperClassConstructor() |
ObjectTypeI |
getTopDefiningInterface(String propName) |
TypeI |
getTypeOfThis()
Gets the type of
this in this function. |
protected abstract String |
getTypeVar() |
Iterable<TypeI> |
getUnionMembers()
If this type is a union type, returns a list of its members.
|
boolean |
hasConstantProp(QualifiedName pname) |
int |
hashCode() |
boolean |
hasInstanceType() |
boolean |
hasNonScalar() |
boolean |
hasOwnProperty(String propertyName) |
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 |
isBoxableScalar() |
boolean |
isConstructor() |
boolean |
isDict() |
boolean |
isEnumElement() |
boolean |
isEnumObject() |
boolean |
isEquivalentTo(TypeI type) |
boolean |
isFalseOrFalsy() |
boolean |
isFunctionType() |
boolean |
isFunctionWithProperties() |
boolean |
isGeneric() |
boolean |
isInstanceofObject() |
boolean |
isInstanceType()
Whether this type is an instance object of some constructor.
|
boolean |
isInterface() |
boolean |
isInterfaceDefinition() |
boolean |
isInterfaceInstance() |
boolean |
isIObject() |
boolean |
isLegacyNamedType()
The old type checker uses NamedType to wrap types (e.g., defined by typedefs), and to represent
unresolved forward declares.
|
boolean |
isLoose() |
boolean |
isNamespace() |
boolean |
isNonClassyObject() |
boolean |
isNonLooseSubtypeOf(JSType other) |
boolean |
isNullable() |
boolean |
isNullOrUndef() |
boolean |
isNullType() |
boolean |
isNumber() |
boolean |
isObjectType() |
boolean |
isPropDefinedOnSubtype(QualifiedName pname) |
boolean |
isPrototypeObject() |
boolean |
isScalar() |
boolean |
isSingletonObj() |
boolean |
isSomeUnknownType() |
boolean |
isString() |
boolean |
isStruct() |
boolean |
isStructuralInterface() |
boolean |
isStructWithoutProp(QualifiedName pname) |
boolean |
isSubtypeOf(TypeI other) |
boolean |
isTop() |
boolean |
isTrueOrTruthy() |
boolean |
isTypeVariable() |
boolean |
isUndefined() |
boolean |
isUnion() |
boolean |
isUnionType() |
boolean |
isUnknown() |
boolean |
isUnknownObject() |
boolean |
isUnknownType() |
boolean |
isUnresolved() |
boolean |
isUnresolvedOrResolvedUnknown() |
boolean |
isVoidable() |
boolean |
isVoidType() |
static JSType |
join(JSType lhs,
JSType rhs) |
boolean |
mayBeDict() |
boolean |
mayBeStruct() |
boolean |
mayContainUnknownObject() |
boolean |
mayHaveProp(QualifiedName qname) |
static JSType |
meet(JSType lhs,
JSType rhs) |
TypeI |
meetWith(TypeI other) |
JSType |
negate() |
ObjectTypeI |
normalizeObjectForCheckAccessControls()
Works around the OTI distinction between prototype-object types and other objects.
|
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.
|
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 TYPEVAR_MASK
protected static final int NON_SCALAR_MASK
protected static final int NULL_MASK
public static boolean mockToString
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 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 boolean hasNonScalar()
public boolean isNullable()
isNullable in interface TypeIpublic boolean isTypeVariable()
isTypeVariable in interface TypeIpublic boolean hasTypeVariable()
public boolean isStruct()
public boolean mayBeStruct()
public boolean isStructWithoutProp(QualifiedName pname)
public boolean isLoose()
public boolean isDict()
public JSType getIndexType()
public JSType getIndexedType()
public boolean mayBeDict()
public boolean isEnumElement()
isEnumElement in interface TypeIpublic boolean isEnumObject()
isEnumObject in interface TypeIpublic boolean isUnion()
public boolean isFunctionWithProperties()
public boolean isNamespace()
public JSType getEnumeratedTypeOfEnumElement()
getEnumeratedTypeOfEnumElement in interface TypeIpublic 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 isIObject()
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 boolean isPropDefinedOnSubtype(QualifiedName pname)
public StringBuilder appendTo(StringBuilder builder)
public boolean isConstructor()
isConstructor 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 boolean isSomeUnknownType()
isSomeUnknownType in interface TypeIpublic boolean isUnresolved()
isUnresolved in interface TypeIpublic boolean isUnresolvedOrResolvedUnknown()
isUnresolvedOrResolvedUnknown in interface TypeIpublic boolean isUnionType()
isUnionType in interface TypeIpublic boolean isVoidable()
isVoidable in interface TypeIpublic boolean isNullType()
isNullType in interface TypeIpublic boolean isVoidType()
isVoidType in interface TypeIpublic TypeI restrictByNotNullOrUndefined()
TypeIrestrictByNotNullOrUndefined in interface TypeIpublic FunctionTypeI toMaybeFunctionType()
TypeItoMaybeFunctionType in interface TypeIpublic ObjectTypeI toMaybeObjectType()
TypeItoMaybeObjectType in interface TypeIpublic ObjectTypeI autoboxAndGetObject()
autoboxAndGetObject in interface TypeIpublic String getDisplayName()
getDisplayName in interface TypeIpublic TypeI convertMethodToFunction()
FunctionTypeIconvertMethodToFunction in interface FunctionTypeIpublic boolean hasInstanceType()
hasInstanceType 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 acceptsArguments(List<? extends TypeI> argumentTypes)
FunctionTypeIacceptsArguments 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 FunctionTypeI getSuperClassConstructor()
getSuperClassConstructor in interface ObjectTypeIpublic JSType getPrototypeObject()
ObjectTypeIgetPrototypeObject in interface ObjectTypeIpublic JSDocInfo getJSDocInfo()
getJSDocInfo in interface TypeIpublic JSDocInfo getOwnPropertyJSDocInfo(String propertyName)
getOwnPropertyJSDocInfo in interface ObjectTypeIpublic JSDocInfo getPropertyJSDocInfo(String propertyName)
getPropertyJSDocInfo in interface ObjectTypeIpublic Node getOwnPropertyDefSite(String propertyName)
getOwnPropertyDefSite in interface ObjectTypeIpublic Node getPropertyDefSite(String propertyName)
getPropertyDefSite in interface ObjectTypeIpublic Iterable<String> getOwnPropertyNames()
getOwnPropertyNames in interface ObjectTypeIpublic boolean isPrototypeObject()
isPrototypeObject in interface TypeIpublic boolean isUnknownObject()
isUnknownObject in interface ObjectTypeIpublic boolean isInstanceofObject()
isInstanceofObject in interface TypeIpublic boolean mayContainUnknownObject()
public boolean isInstanceType()
ObjectTypeIisInstanceType in interface ObjectTypeIpublic boolean hasProperty(String propertyName)
hasProperty in interface ObjectTypeIpublic Iterable<TypeI> getUnionMembers()
TypeIgetUnionMembers in interface TypeIpublic ObjectTypeI normalizeObjectForCheckAccessControls()
ObjectTypeInormalizeObjectForCheckAccessControls in interface ObjectTypeIpublic boolean isBoxableScalar()
isBoxableScalar in interface TypeIpublic final boolean isObjectType()
isObjectType in interface TypeIpublic final boolean isGeneric()
isGeneric in interface ObjectTypeIpublic Collection<ObjectTypeI> getAncestorInterfaces()
getAncestorInterfaces in interface FunctionTypeIpublic boolean isStructuralInterface()
isStructuralInterface in interface TypeIpublic boolean hasOwnProperty(String propertyName)
hasOwnProperty in interface ObjectTypeIpublic ObjectTypeI getRawType()
getRawType in interface ObjectTypeIpublic final boolean isLegacyNamedType()
ObjectTypeIisLegacyNamedType in interface ObjectTypeIpublic TypeI getLegacyResolvedType()
ObjectTypeIgetLegacyResolvedType in interface ObjectTypeIpublic TypeI getGreatestSubtypeWithProperty(String pname)
getGreatestSubtypeWithProperty in interface TypeIpublic Collection<JSType> getDirectImplementors()
getDirectImplementors in interface ObjectTypeIpublic ObjectTypeI getPrototypeProperty()
getPrototypeProperty in interface FunctionTypeIpublic ObjectTypeI getTopDefiningInterface(String propName)
getTopDefiningInterface in interface ObjectTypeIpublic FunctionTypeI getOwnerFunction()
getOwnerFunction in interface ObjectTypeICopyright © 2009-2017 Google. All Rights Reserved.