Class PrototypeObjectType
- Direct Known Subclasses:
EnumType,FunctionType,RecordType
Object, Date, Function.Objects in JavaScript are unordered collections of properties. Each property consists of a name, a value and a set of attributes.
Each instance has an implicit prototype property ([[Prototype]])
pointing to an object instance, which itself has an implicit property, thus
forming a chain.
A class begins life with no name. Later, a name may be provided once it
can be inferred. Note that the name in this case is strictly for
debugging purposes. Looking up type name references goes through the
JSTypeRegistry.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.javascript.rhino.jstype.JSType
JSType.HasPropertyKind, JSType.Nullability, JSType.SubtypingMode, JSType.TypePair, JSType.WithSourceRef -
Field Summary
Fields inherited from class com.google.javascript.rhino.jstype.JSType
templateTypeMap -
Method Summary
Modifier and TypeMethodDescriptionGets this object's constructor.Gets the interfaces extended by the interface associated with this type.Gets the interfaces implemented by the ctor associated with this type.Gets the implicit prototype (a.k.a.@Nullable StringGets the reference name for this object.final intReturn the number of template parameters declared for this type.booleanbooleanWhether this is a built-in object.voidmatchConstraint(JSType constraint) Modify this type so that it matches the specified type.booleanThis predicate is used to test whether a given type can appear in a numeric context, such as an operand of a multiply operator.booleanThis predicate is used to test whether a given type can appear in anObjectcontext, such as the expression in a with statement.booleanThis predicate is used to test whether a given type can appear in aStringcontext, such as an operand of a string concat (+) operator.booleanThis predicate is used to test whether a given type can appear in asymbolcontext such as property access.voidmatchRecordTypeConstraint(ObjectType constraintObj) voidsetPropertyJSDocInfo(Property.Key propertyName, JSDocInfo info) Sets the docInfo for the specified property from theJSDocInfoon its definition.voidsetPropertyNode(Property.Key propertyName, Node defSite) Sets the node where the property was defined.Methods inherited from class com.google.javascript.rhino.jstype.ObjectType
cast, clearCachedValues, createDelegateSuffix, defineDeclaredProperty, defineDeclaredProperty, defineInferredProperty, defineInferredProperty, defineSynthesizedProperty, findClosestDefinition, findClosestDefinition, findPropertyTypeWithoutConsideringTemplateTypes, getAllKeys, getClosestDefiningType, getDisplayName, getEnumeratedTypeOfEnumObject, getImplicitPrototypeChain, getJSDocInfo, getNormalizedReferenceName, getOwnPropertyDefSite, getOwnPropertyDefSite, getOwnPropertyJSDocInfo, getOwnPropertyJSDocInfo, getOwnPropertyKeys, getOwnPropertyKind, getOwnPropertyKind, getOwnPropertyKnownSymbols, getOwnPropertyNames, getOwnSlot, getOwnSlot, getPossibleToBooleanOutcomes, getPropertiesCount, getPropertyDefSite, getPropertyDefSite, getPropertyJSDocInfo, getPropertyJSDocInfo, getPropertyKind, getPropertyNames, getPropertyNode, getPropertyNode, getPropertyType, getPropertyType, getPropertyTypeMap, getRawType, getSlot, getSlot, getSuperClassConstructor, getTemplateTypes, getTypeOfThis, hasCachedValues, hasOwnDeclaredProperty, hasOwnDeclaredProperty, hasOwnProperty, hasOwnProperty, hasReferenceName, isFunctionPrototypeType, isObject, isPropertyInExterns, isPropertyTypeDeclared, isPropertyTypeDeclared, isPropertyTypeInferred, isPropertyTypeInferred, isStructuralType, isUnknownType, setJSDocInfo, setPropertyJSDocInfo, setPropertyNode, testForEquality, visitMethods inherited from class com.google.javascript.rhino.jstype.JSType
areSimilar, assertFunctionType, assertObjectType, autobox, autoboxesTo, canBeCalled, canCastTo, canTestForEqualityWith, canTestForShallowEqualityWith, collapseUnion, containsReferenceAncestor, dereference, differsFrom, equals, findPropertyType, findPropertyType, getEnumeratedTypeOfEnumElement, getGreatestSubtype, getLeastSupertype, getPropertyKind, getPropertyKind, getPropertyKind, getRestrictedTypeGivenOutcome, getTemplateTypeMap, getTypeParameters, getTypesUnderEquality, getTypesUnderInequality, getTypesUnderShallowEquality, getTypesUnderShallowInequality, getUnionMembers, hasAnyTemplateTypes, hasDisplayName, hashCode, hasProperty, hasProperty, isAllType, isArrayType, isBigIntObjectType, isBigIntOrNumber, isBigIntValueType, isBooleanObjectType, isBooleanValueType, isBoxableScalar, isCheckedUnknownType, isConstructor, isDateType, isDict, isEmptyType, isEnumElementType, isEnumType, isExplicitlyVoidable, isFunctionType, isGlobalThisType, isInstanceType, isInterface, isKnownSymbolValueType, isLiteralObject, isNamedType, isNominalConstructorOrInterface, isNominalType, isNoObjectType, isNoResolvedType, isNoType, isNullable, isNullType, isNumber, isNumberObjectType, isNumberValueType, isObjectType, isOnlyBigInt, isOrdinaryFunction, isRawTypeOfTemplatizedType, isReadonlyArrayType, isRecordType, isRegexpType, isResolved, isSomeUnknownType, isString, isStringObjectType, isStringValueType, isStruct, isStructuralInterface, isSubtype, isSubtype, isSubtypeOf, isSubtypeOf, isSubtypeWithoutStructuralTyping, isSuccessfullyResolved, isSymbol, isSymbolObjectType, isSymbolValueType, isTemplateType, isTemplatizedType, isUnionType, isUnsuccessfullyResolved, isVoidable, isVoidType, loosenTypecheckingDueToForwardReferencedSupertype, mergeSupertypeTemplateTypes, resolve, restrictByNotNull, restrictByNotNullOrUndefined, restrictByNotUndefined, setValidator, toAnnotationString, toMaybeEnumElementType, toMaybeEnumType, toMaybeFunctionType, toMaybeFunctionType, toMaybeKnownSymbolType, toMaybeNamedType, toMaybeObjectType, toMaybeRecordType, toMaybeTemplateType, toMaybeTemplatizedType, toMaybeUnionType, toObjectType, toString
-
Method Details
-
setPropertyJSDocInfo
Description copied from class:ObjectTypeSets the docInfo for the specified property from theJSDocInfoon its definition.- Overrides:
setPropertyJSDocInfoin classObjectType- Parameters:
info-JSDocInfofor the property definition. May benull.
-
setPropertyNode
Description copied from class:ObjectTypeSets the node where the property was defined.- Overrides:
setPropertyNodein classObjectType
-
matchesNumberContext
public boolean matchesNumberContext()Description copied from class:JSTypeThis predicate is used to test whether a given type can appear in a numeric context, such as an operand of a multiply operator.- Overrides:
matchesNumberContextin classJSType
-
matchesStringContext
public boolean matchesStringContext()Description copied from class:JSTypeThis predicate is used to test whether a given type can appear in aStringcontext, such as an operand of a string concat (+) operator. All types have at least the potential for converting toString. When we add externally defined types, such as a browser OM, we may choose to add types that do not automatically convert toString.- Overrides:
matchesStringContextin classJSType
-
matchesSymbolContext
public boolean matchesSymbolContext()Description copied from class:JSTypeThis predicate is used to test whether a given type can appear in asymbolcontext such as property access.- Overrides:
matchesSymbolContextin classJSType
-
matchesObjectContext
public boolean matchesObjectContext()Description copied from class:JSTypeThis predicate is used to test whether a given type can appear in anObjectcontext, such as the expression in a with statement. Most types we will encounter, except notablynull, have at least the potential for converting toObject. Host defined objects can get peculiar.- Overrides:
matchesObjectContextin classJSType
-
getConstructor
Description copied from class:ObjectTypeGets this object's constructor.- Specified by:
getConstructorin classObjectType- Returns:
- this object's constructor or
nullif it is a native object (constructed natively v.s. by instantiation of a function)
-
getImplicitPrototype
Description copied from class:ObjectTypeGets the implicit prototype (a.k.a. the[[Prototype]]property).- Specified by:
getImplicitPrototypein classObjectType
-
getTemplateParamCount
public final int getTemplateParamCount()Description copied from class:JSTypeReturn the number of template parameters declared for this type.In general, this value corresponds to the number of `@template` declarations on the type definition. It does not include template parameters from superclasses or superinterfaces.
- Overrides:
getTemplateParamCountin classJSType
-
getReferenceName
Description copied from class:ObjectTypeGets the reference name for this object. This includes named types like constructors, prototypes, and enums. It notably does not include literal types like strings and booleans and structural types.Returning 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(TypeStringBuilder)- Specified by:
getReferenceNamein classObjectType- Returns:
- the object's name or
nullif this is an anonymous object
-
isAnonymous
public boolean isAnonymous() -
isNativeObjectType
public boolean isNativeObjectType()Whether this is a built-in object.- Overrides:
isNativeObjectTypein classObjectType
-
getOwnerFunction
- Overrides:
getOwnerFunctionin classObjectType
-
getCtorImplementedInterfaces
Description copied from class:ObjectTypeGets the interfaces implemented by the ctor associated with this type. Intended to be overridden by subclasses.- Overrides:
getCtorImplementedInterfacesin classObjectType
-
getCtorExtendedInterfaces
Description copied from class:ObjectTypeGets the interfaces extended by the interface associated with this type. Intended to be overridden by subclasses.- Overrides:
getCtorExtendedInterfacesin classObjectType
-
matchConstraint
Description copied from class:JSTypeModify this type so that it matches the specified type.This is useful for reverse type-inference, where we want to infer that an object literal matches its constraint (much like how the java compiler does reverse-inference to figure out generics).
- Overrides:
matchConstraintin classJSType
-
matchRecordTypeConstraint
-