public class ProxyObjectType extends ObjectType
NamedType,
TemplatizedType,
Serialized FormJSType.HasPropertyKind, JSType.Nullability, JSType.SubtypingMode, JSType.TypePairtemplateTypeMap| Modifier and Type | Method and Description |
|---|---|
boolean |
canBeCalled()
This predicate is used to test whether a given type can be used as the
'function' in a function call.
|
JSType |
collapseUnion()
Gets the least supertype of this that's not a union.
|
protected JSType |
findPropertyTypeWithoutConsideringTemplateTypes(java.lang.String propertyName)
Looks up a property on this type, but without properly replacing any templates in the result.
|
FunctionType |
getConstructor()
Gets this object's constructor.
|
java.lang.Iterable<ObjectType> |
getCtorExtendedInterfaces()
Gets the interfaces extended by the interface associated with this type.
|
java.lang.Iterable<ObjectType> |
getCtorImplementedInterfaces()
Gets the interfaces implemented by the ctor associated with this type.
|
ObjectType |
getImplicitPrototype()
Gets the implicit prototype (a.k.a.
|
JSDocInfo |
getJSDocInfo()
Gets the docInfo for this type.
|
FunctionType |
getOwnerFunction() |
JSType.HasPropertyKind |
getPropertyKind(java.lang.String propertyName,
boolean autobox)
Checks whether the property is present on the object.
|
java.lang.String |
getReferenceName()
Gets the reference name for this object.
|
int |
getTemplateParamCount()
Return the number of template parameters declared for this type.
|
TemplateTypeMap |
getTemplateTypeMap()
Returns the template type map associated with this type.
|
com.google.common.collect.ImmutableList<JSType> |
getTemplateTypes()
Gets the declared default element type.
|
JSType |
getTypeOfThis() |
boolean |
hasAnyTemplateTypesInternal() |
boolean |
isAllType() |
boolean |
isCheckedUnknownType() |
boolean |
isConstructor()
Whether this type is a
FunctionType that is a constructor or a
named type that points to such a type. |
boolean |
isDict()
Returns true iff
this can be a dict. |
boolean |
isInstanceType()
Whether this type is an Instance object of some constructor.
|
boolean |
isInterface()
Whether this type is a
FunctionType that is an interface or a named
type that points to such a type. |
boolean |
isNativeObjectType()
Whether this is a built-in object.
|
boolean |
isNominalType()
Whether this type is a nominal type (a named instance object or
a named enum).
|
boolean |
isNoObjectType() |
boolean |
isNoResolvedType() |
boolean |
isNoType() |
boolean |
isNullable()
Tests whether this type is nullable.
|
boolean |
isOrdinaryFunction()
Whether this type is a
FunctionType that is an ordinary function (i.e. |
boolean |
isStruct()
Returns true iff
this can be a struct. |
boolean |
isStructuralType() |
boolean |
isUnknownType()
We treat this as the unknown type if any of its implicit prototype
properties is unknown.
|
boolean |
isVoidable()
Tests whether this type is voidable.
|
void |
matchConstraint(JSType constraint)
Modify this type so that it matches the specified type.
|
boolean |
matchesNumberContext()
This predicate is used to test whether a given type can appear in a numeric context, such as an
operand of a multiply operator.
|
boolean |
matchesObjectContext()
This predicate is used to test whether a given type can appear in an
Object context, such as the expression in a with statement. |
boolean |
matchesStringContext()
This predicate is used to test whether a given type can appear in a
String context, such as an operand of a string concat (+) operator. |
boolean |
matchesSymbolContext()
This predicate is used to test whether a given type can appear in a
symbol context such as property access. |
boolean |
removeProperty(java.lang.String name)
Removes the declared or inferred property from this ObjectType.
|
void |
setJSDocInfo(JSDocInfo info)
Sets the docInfo for this type from the given
JSDocInfo. |
void |
setPropertyJSDocInfo(java.lang.String propertyName,
JSDocInfo info)
Sets the docInfo for the specified property from the
JSDocInfo on its definition. |
boolean |
setValidator(com.google.common.base.Predicate<JSType> validator)
Certain types have constraints on them at resolution-time.
|
TernaryValue |
testForEquality(JSType that)
Compares
this and that. |
java.lang.String |
toDebugHashCodeString()
A hash code function for diagnosing complicated issues
around type-identity.
|
EnumElementType |
toMaybeEnumElementType()
Downcasts this to an EnumElementType, or returns null if this is not an EnumElementType.
|
EnumType |
toMaybeEnumType()
Downcasts this to an EnumType, or returns null if this is not an EnumType.
|
FunctionType |
toMaybeFunctionType()
Downcasts this to a FunctionType, or returns null if this is not a function.
|
RecordType |
toMaybeRecordType()
Downcasts this to a RecordType, or returns null if this is not
a RecordType.
|
TemplateType |
toMaybeTemplateType()
Downcasts this to a TemplateType, or returns null if this is not
a function.
|
TemplatizedType |
toMaybeTemplatizedType()
Downcasts this to a TemplatizedType, or returns null if this is not
a function.
|
UnionType |
toMaybeUnionType()
Downcasts this to a UnionType, or returns null if this is not a UnionType.
|
<T> T |
visit(Visitor<T> visitor)
Visit this type with the given visitor.
|
<T> T |
visitReferenceType(Visitor<T> visitor) |
cast, clearCachedValues, createDelegateSuffix, defineDeclaredProperty, defineInferredProperty, defineSynthesizedProperty, findClosestDefinition, getClosestDefiningType, getDisplayName, getEnumeratedTypeOfEnumObject, getImplicitPrototypeChain, getNormalizedReferenceName, getOwnPropertyDefSite, getOwnPropertyJSDocInfo, getOwnPropertyKind, getOwnPropertyNames, getOwnSlot, getPossibleToBooleanOutcomes, getPropertiesCount, getPropertyDefSite, getPropertyJSDocInfo, getPropertyNames, getPropertyNode, getPropertyType, getPropertyTypeMap, getRawType, getSlot, getSuperClassConstructor, getTopMostDefiningType, hasCachedValues, hasOwnProperty, hasReferenceName, isAmbiguousObject, isFunctionPrototypeType, isObject, isPropertyInExterns, isPropertyTypeDeclared, isPropertyTypeInferred, setPropertyNodeassertFunctionType, assertObjectType, autobox, autoboxesTo, canCastTo, canTestForEqualityWith, canTestForShallowEqualityWith, containsReferenceAncestor, dereference, differsFrom, equals, findPropertyType, getEnumeratedTypeOfEnumElement, getGreatestSubtype, getGreatestSubtypeWithProperty, getLeastSupertype, getPropertyKind, getRestrictedTypeGivenToBooleanOutcome, getTypeParameters, getTypesUnderEquality, getTypesUnderInequality, getTypesUnderShallowEquality, getTypesUnderShallowInequality, getUnionMembers, hasAnyTemplateTypes, hasDisplayName, hashCode, hasProperty, isArrayType, isBooleanObjectType, isBooleanValueType, isBoxableScalar, isDateType, isEmptyType, isEnumElementType, isEnumType, isEquivalent, isEquivalentTo, isEquivalentTo, isExplicitlyVoidable, isFunctionType, isGlobalThisType, isLiteralObject, isNamedType, isNominalConstructor, isNullType, isNumber, isNumberObjectType, isNumberValueType, isObjectType, isRawTypeOfTemplatizedType, isRecordType, isRegexpType, isResolved, isSomeUnknownType, isString, isStringObjectType, isStringValueType, isStructuralInterface, isSubtype, isSubtype, isSubtypeOf, isSubtypeOf, isSubtypeWithoutStructuralTyping, isSuccessfullyResolved, isSymbol, isSymbolObjectType, isSymbolValueType, isTemplateType, isTemplatizedType, isTypeVariable, isUnionType, isUnresolved, isUnresolvedOrResolvedUnknown, isUnsuccessfullyResolved, isVoidType, mergeSupertypeTemplateTypes, resolve, restrictByNotNull, restrictByNotNullOrUndefined, restrictByNotUndefined, toAnnotationString, toMaybeFunctionType, toMaybeNamedType, toMaybeObjectType, toObjectType, toString, unboxesTopublic final JSType.HasPropertyKind getPropertyKind(java.lang.String propertyName, boolean autobox)
JSTypegetPropertyKind in class ObjectTypepropertyName - The property name.autobox - Whether to check for the presents on an autoboxed typepublic boolean setValidator(com.google.common.base.Predicate<JSType> validator)
JSType@extends annotation must be an
object. Clients should inject a validator that emits a warning
if the type does not validate, and return false.setValidator in class JSTypepublic java.lang.String getReferenceName()
ObjectTypeReturning an empty string means something different than returning null. An empty string may
indicate an anonymous constructor, which we treat differently than a literal type without a
reference name. e.g. in InstanceObjectType.appendTo(StringBuilder, boolean)
getReferenceName in class ObjectTypenull if this is an anonymous objectpublic final boolean matchesNumberContext()
JSTypematchesNumberContext in class JSTypepublic final boolean matchesStringContext()
JSTypeString context, such as an operand of a string concat (+) operator.
All types have at least the potential for converting to String.
When we add externally defined types, such as a browser OM, we may choose
to add types that do not automatically convert to String.matchesStringContext in class JSTypepublic final boolean matchesSymbolContext()
JSTypesymbol context such as property access.matchesSymbolContext in class JSTypepublic final boolean matchesObjectContext()
JSTypeObject context, such as the expression in a with statement.
Most types we will encounter, except notably null, have at least
the potential for converting to Object. Host defined objects can
get peculiar.matchesObjectContext in class JSTypepublic final boolean canBeCalled()
JSTypecanBeCalled in class JSTypetrue if this type might be callable.public final boolean isStructuralType()
isStructuralType in class ObjectTypepublic final boolean isNoObjectType()
isNoObjectType in class JSTypepublic final boolean isNoResolvedType()
isNoResolvedType in class JSTypepublic final boolean isUnknownType()
ObjectTypeisUnknownType in class ObjectTypepublic final boolean isCheckedUnknownType()
isCheckedUnknownType in class JSTypepublic final boolean isNullable()
JSTypeisNullable in class JSTypepublic final boolean isVoidable()
JSTypeisVoidable in class JSTypepublic final EnumType toMaybeEnumType()
JSTypetoMaybeEnumType in class JSTypepublic final boolean isConstructor()
JSTypeFunctionType that is a constructor or a
named type that points to such a type.isConstructor in class JSTypepublic boolean isNominalType()
JSTypeisNominalType in class JSTypepublic final boolean isInstanceType()
JSTypeInstanceObjectType.isInstanceType in class JSTypepublic final boolean isInterface()
JSTypeFunctionType that is an interface or a named
type that points to such a type.isInterface in class JSTypepublic final boolean isOrdinaryFunction()
JSTypeFunctionType that is an ordinary function (i.e. not a
constructor, nominal interface, or record interface), or a named type that points to such a
type.isOrdinaryFunction in class JSTypepublic final boolean isStruct()
JSTypethis can be a struct.
UnionType overrides the method, assume this is not a union here.public final boolean isDict()
JSTypethis can be a dict.
UnionType overrides the method, assume this is not a union here.public final boolean isNativeObjectType()
ObjectTypeisNativeObjectType in class ObjectTypepublic final RecordType toMaybeRecordType()
JSTypetoMaybeRecordType in class JSTypepublic final UnionType toMaybeUnionType()
JSTypetoMaybeUnionType in class JSTypepublic final FunctionType toMaybeFunctionType()
JSTypeFor the purposes of this function, we define a MaybeFunctionType as any type in the sub-lattice { x | LEAST_FUNCTION_TYPE <= x <= GREATEST_FUNCTION_TYPE } This definition excludes bottom types like NoType and NoObjectType.
This definition is somewhat arbitrary and axiomatic, but this is the definition that makes the most sense for the most callers.
toMaybeFunctionType in class JSTypepublic final EnumElementType toMaybeEnumElementType()
JSTypetoMaybeEnumElementType in class JSTypepublic final TernaryValue testForEquality(JSType that)
JSTypethis and that.testForEquality in class ObjectTypeTernaryValue.TRUE if the comparison of values of
this type and that always succeed (such as
undefined compared to null)TernaryValue.FALSE if the comparison of values of
this type and that always fails (such as
undefined compared to number)TernaryValue.UNKNOWN if the comparison can succeed or
fail depending on the concrete valuespublic final FunctionType getOwnerFunction()
getOwnerFunction in class ObjectTypepublic java.lang.Iterable<ObjectType> getCtorImplementedInterfaces()
ObjectTypegetCtorImplementedInterfaces in class ObjectTypepublic java.lang.Iterable<ObjectType> getCtorExtendedInterfaces()
ObjectTypegetCtorExtendedInterfaces in class ObjectTypepublic final ObjectType getImplicitPrototype()
ObjectType[[Prototype]] property).getImplicitPrototype in class ObjectTypepublic final boolean removeProperty(java.lang.String name)
ObjectTyperemoveProperty in class ObjectTypename - the property's nameprotected JSType findPropertyTypeWithoutConsideringTemplateTypes(java.lang.String propertyName)
JSTypeSubclasses can override this if they need more complicated logic for property lookup than just autoboxing to an object.
This is only for use by findPropertyType(JSType). Call that method instead if you
need to lookup a property on a random JSType
findPropertyTypeWithoutConsideringTemplateTypes in class ObjectTypepublic final JSDocInfo getJSDocInfo()
ObjectTypegetJSDocInfo in class ObjectTypepublic final void setJSDocInfo(JSDocInfo info)
ObjectTypesetJSDocInfo in class ObjectTypepublic final void setPropertyJSDocInfo(java.lang.String propertyName,
JSDocInfo info)
ObjectTypeJSDocInfo on its definition.setPropertyJSDocInfo in class ObjectTypeinfo - JSDocInfo for the property definition. May be
null.public final FunctionType getConstructor()
ObjectTypegetConstructor in class ObjectTypenull if it is a native
object (constructed natively v.s. by instantiation of a function)public com.google.common.collect.ImmutableList<JSType> getTemplateTypes()
ObjectTypegetTemplateTypes in class ObjectTypeTemplatizedTypepublic int getTemplateParamCount()
JSTypeIn general, this value corresponds to the number of `@template` declarations on the type definition. It does not include template parameters from superclasses or superinterfaces.
getTemplateParamCount in class JSTypepublic final <T> T visitReferenceType(Visitor<T> visitor)
public <T> T visit(Visitor<T> visitor)
JSTypevisit in class ObjectTypeVisitorpublic final java.lang.String toDebugHashCodeString()
JSTypetoDebugHashCodeString in class JSTypepublic final JSType getTypeOfThis()
getTypeOfThis in class ObjectTypepublic final JSType collapseUnion()
JSTypecollapseUnion in class JSTypepublic final void matchConstraint(JSType constraint)
JSTypematchConstraint in class JSTypepublic TemplatizedType toMaybeTemplatizedType()
JSTypetoMaybeTemplatizedType in class JSTypepublic TemplateType toMaybeTemplateType()
JSTypetoMaybeTemplateType in class JSTypepublic boolean hasAnyTemplateTypesInternal()
public TemplateTypeMap getTemplateTypeMap()
JSTypegetTemplateTypeMap in class JSTypeCopyright © 2009-2019 Google. All Rights Reserved.