public class FunctionType extends PrototypeObjectType implements FunctionTypeI
Note: the parameters list is the PARAM_LIST node that is the parent of the actual NAME node containing the parsed argument list (annotated with JSDOC_TYPE_PROP's for the compile-time type of each argument.
JSType.HasPropertyKind, JSType.SubtypingMode, JSType.TypePairFunctionTypeI.BuilderTypeI.Nullability, TypeI.TypeInferencetemplateTypeMap| Modifier and Type | Method and Description |
|---|---|
boolean |
acceptsArguments(java.util.List<? extends TypeI> argumentTypes)
Checks if a call to this function with the given list of arguments is valid.
|
boolean |
canBeCalled()
This predicate is used to test whether a given type can be used as the
'function' in a function call.
|
java.util.List<FunctionType> |
checkExtendsLoop()
check if there is a loop in the type extends chain
|
java.util.List<FunctionType> |
checkExtendsLoop(java.util.HashSet<FunctionType> cache,
java.util.List<FunctionType> path) |
void |
clearCachedValues()
Clear cached values.
|
TypeI |
convertMethodToFunction()
Creates a new function type B based on the original function type A.
|
boolean |
explicitlyImplOrExtInterface(FunctionType interfaceType)
check whether or not this function type has implemented the given interface if this function is
an interface, check whether or not this interface has extended the given interface
|
void |
extendTemplateTypeMapBasedOn(ObjectType type)
Extends the TemplateTypeMap of the function's this type, based on the specified type.
|
java.lang.Iterable<ObjectType> |
getAllImplementedInterfaces()
Returns all interfaces implemented by a class or its superclass and any superclasses for any of
those interfaces.
|
java.util.Collection<ObjectTypeI> |
getAncestorInterfaces() |
FunctionType |
getBindReturnType(int argsToBind)
Get the return value of calling "bind" on this function with the specified number of arguments.
|
java.lang.Iterable<FunctionTypeI> |
getDirectSubTypes()
Returns an iterable of direct types that are subtypes of this type.
|
java.lang.Iterable<ObjectType> |
getExtendedInterfaces()
Returns interfaces directly extended by an interface
|
int |
getExtendedInterfacesCount()
Returns the number of interfaces directly extended by an interface
|
java.lang.Iterable<ObjectType> |
getImplementedInterfaces()
Returns interfaces implemented directly by a class or its superclass.
|
ObjectType |
getInstanceType()
Gets the type of instance of this function.
|
int |
getMaxArity()
Gets the maximum number of arguments that this function requires, or Integer.MAX_VALUE if this
is a variable argument function.
|
int |
getMinArity()
Gets the minimum number of arguments that this function requires.
|
java.lang.Iterable<ObjectType> |
getOwnImplementedInterfaces()
Returns interfaces directly implemented by the class.
|
java.util.Set<java.lang.String> |
getOwnPropertyNames()
Includes the prototype iff someone has created it.
|
java.lang.Iterable<Node> |
getParameters() |
Node |
getParametersNode()
Gets a PARAM_LIST node that contains all params.
|
java.lang.Iterable<TypeI> |
getParameterTypes() |
JSType |
getPropertyType(java.lang.String name)
Gets the property type of the property whose name is given.
|
java.util.Map<java.lang.String,JSType> |
getPropertyTypeMap()
get the map of properties to types covered in a function type
|
ObjectType |
getPrototype()
Gets the
prototype property of this function type. |
ObjectType |
getPrototypeProperty() |
JSType |
getReturnType() |
Property |
getSlot(java.lang.String name)
Default getSlot implementation.
|
Node |
getSource()
Gets the source node or null if this is an unknown function.
|
FunctionType |
getSuperClassConstructor()
Given a constructor or an interface type, get its superclass constructor or
null if
none exists. |
ObjectType |
getTopMostDefiningType(java.lang.String propertyName)
Given a constructor or an interface type and a property, finds the top-most superclass that has
the property defined (including this constructor).
|
JSType |
getTypeOfThis()
Gets the type of
this in this function. |
boolean |
hasAnyTemplateTypesInternal() |
boolean |
hasCachedValues()
Returns true if any cached values have been set for this type.
|
boolean |
hasEqualCallType(FunctionType otherType) |
int |
hashCode() |
boolean |
hasImplementedInterfaces() |
boolean |
hasInstanceType()
Returns whether this function type has an instance type.
|
boolean |
hasProperties()
Whether this function type has any properties (not counting "prototype").
|
boolean |
isAbstract() |
boolean |
isConstructor()
Whether this type is a
FunctionType that is a constructor or a
named type that points to such a type. |
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 |
isOrdinaryFunction()
Whether this type is a
FunctionType that is an ordinary function or
a named type that points to such a type. |
boolean |
isReturnTypeInferred() |
boolean |
isStructuralInterface() |
boolean |
isSubtype(JSType that)
A function is a subtype of another if their call methods are related via subtyping and
this is a subtype of that with regard to the prototype chain. |
protected boolean |
isSubtype(JSType that,
com.google.javascript.rhino.jstype.JSType.ImplCache implicitImplCache,
JSType.SubtypingMode subtypingMode)
checking isSubtype with structural interface matching
|
boolean |
makesDicts()
When a class B inherits from A and A is annotated as a dict, then B automatically gets the
annotation, even if B's constructor is not explicitly annotated.
|
boolean |
makesStructs()
When a class B inherits from A and A is annotated as a struct, then B automatically gets the
annotation, even if B's constructor is not explicitly annotated.
|
void |
setDict() |
void |
setExtendedInterfaces(java.util.List<ObjectType> extendedInterfaces) |
void |
setImplementedInterfaces(java.util.List<ObjectType> implementedInterfaces) |
void |
setImplicitMatch(boolean flag)
sets the current interface type to support structural interface matching (abbr.
|
void |
setPrototypeBasedOn(ObjectType baseType)
Sets the prototype, creating the prototype object from the given base type.
|
void |
setSource(Node source)
Sets the source node.
|
void |
setStruct() |
FunctionTypeI.Builder |
toBuilder()
Returns a Builder instance initialized to this function.
|
java.lang.String |
toDebugHashCodeString()
A hash code function for diagnosing complicated issues
around type-identity.
|
FunctionType |
toMaybeFunctionType()
Downcasts this to a FunctionType, or returns null if this is not
a function.
|
<T> T |
visit(Visitor<T> visitor)
Visit this type with the given visitor.
|
getConstructor, getCtorExtendedInterfaces, getCtorImplementedInterfaces, getImplicitPrototype, getOwnerFunction, getReferenceName, hasReferenceName, isAnonymous, isNativeObjectType, matchConstraint, matchesNumberContext, matchesObjectContext, matchesStringContext, matchesSymbolContext, matchRecordTypeConstraint, removeProperty, setPropertyJSDocInfo, setPropertyNode, unboxesTocast, createDelegateSuffix, defineDeclaredProperty, defineInferredProperty, defineSynthesizedProperty, findPropertyType, getDisplayName, getEnumeratedTypeOfEnumObject, getInstantiatedTypeArgument, getJSDocInfo, getLegacyResolvedType, getNormalizedReferenceName, getOwnPropertyDefSite, getOwnPropertyJSDocInfo, getOwnPropertyKind, getOwnSlot, getParentScope, getPossibleToBooleanOutcomes, getPropertiesCount, getPropertyDefSite, getPropertyJSDocInfo, getPropertyKind, getPropertyNames, getPropertyNode, getPrototypeObject, getRawType, getTemplateTypes, getTopDefiningInterface, hasOwnProperty, instantiateGenericsWithUnknown, isAmbiguousObject, isFunctionPrototypeType, isObject, isPropertyInExterns, isPropertyTypeDeclared, isPropertyTypeInferred, isStructuralType, isUnknownType, normalizeObjectForCheckAccessControls, setJSDocInfo, testForEquality, withoutStrayPropertiesautobox, autoboxAndGetObject, autoboxesTo, canCastTo, canTestForEqualityWith, canTestForShallowEqualityWith, collapseUnion, containsArray, dereference, differsFrom, equals, extendTemplateTypeMap, getEnumeratedTypeOfEnumElement, getGreatestSubtype, getGreatestSubtypeWithProperty, getLeastSupertype, getPropertyKind, getRestrictedTypeGivenToBooleanOutcome, getTemplateTypeMap, getTypeParameters, getTypesUnderEquality, getTypesUnderInequality, getTypesUnderShallowEquality, getTypesUnderShallowInequality, getUnionMembers, hasAnyTemplateTypes, hasDisplayName, hasProperty, isAllType, isArrayType, isBooleanObjectType, isBooleanValueType, isBottom, isBoxableScalar, isCheckedUnknownType, isDateType, isDict, isEmptyType, isEnumElement, isEnumElementType, isEnumObject, isEnumType, isEquivalent, isEquivalentTo, isEquivalentTo, isExplicitlyVoidable, isFullyInstantiated, isFunctionType, isGenericObjectType, isGlobalThisType, isInstanceofObject, isLegacyNamedType, isLiteralObject, isNamedType, isNominalConstructor, isNominalType, isNoObjectType, isNoResolvedType, isNoType, isNullable, isNullType, isNumber, isNumberObjectType, isNumberValueType, isObjectType, isPartiallyInstantiated, isPrototypeObject, isRecordType, isRegexpType, isResolved, isSomeUnknownType, isString, isStringObjectType, isStringValueType, isStruct, isSubtype, isSubtypeOf, isSubtypeWithoutStructuralTyping, isSymbol, isSymbolObjectType, isSymbolValueType, isTemplateType, isTemplatizedType, isTop, isTypeVariable, isUnionType, isUnresolved, isUnresolvedOrResolvedUnknown, isVoidable, isVoidType, meetWith, resolve, restrictByNotNullOrUndefined, setValidator, toAnnotationString, toMaybeEnumElementType, toMaybeEnumType, toMaybeFunctionType, toMaybeNamedType, toMaybeObjectType, toMaybeRecordType, toMaybeTemplateType, toMaybeTemplatizedType, toMaybeUnionType, toObjectType, toString, typeInferenceclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetReferenceNamegetConstructor, getEnumeratedTypeOfEnumObject, getInstantiatedTypeArgument, getLegacyResolvedType, getOwnerFunction, getOwnPropertyDefSite, getOwnPropertyJSDocInfo, getPropertyDefSite, getPropertyJSDocInfo, getPropertyNames, getPrototypeObject, getRawType, getTemplateTypes, getTopDefiningInterface, hasOwnProperty, hasProperty, instantiateGenericsWithUnknown, isAmbiguousObject, isLegacyNamedType, normalizeObjectForCheckAccessControls, withoutStrayPropertiesautobox, autoboxAndGetObject, containsArray, getDisplayName, getEnumeratedTypeOfEnumElement, getGreatestSubtypeWithProperty, getJSDocInfo, getTypeParameters, getUnionMembers, isBooleanValueType, isBottom, isBoxableScalar, isEnumElement, isEnumObject, isEquivalentTo, isFullyInstantiated, isFunctionType, isGenericObjectType, isInstanceofObject, isLiteralObject, isNullable, isNullType, isNumberValueType, isObjectType, isPartiallyInstantiated, isPrototypeObject, isRecordType, isSomeUnknownType, isStringValueType, isSubtypeOf, isSubtypeWithoutStructuralTyping, isTop, isTypeVariable, isUnionType, isUnknownType, isUnresolved, isUnresolvedOrResolvedUnknown, isVoidable, isVoidType, meetWith, restrictByNotNullOrUndefined, toAnnotationString, toMaybeObjectType, typeInferencepublic boolean isInstanceType()
JSTypeInstanceObjectType.isInstanceType in interface ObjectTypeIisInstanceType in class JSTypepublic boolean isConstructor()
JSTypeFunctionType that is a constructor or a
named type that points to such a type.isConstructor in interface TypeIisConstructor in class JSTypepublic boolean isInterface()
JSTypeFunctionType that is an interface or a named
type that points to such a type.isInterface in interface TypeIisInterface in class JSTypepublic boolean isOrdinaryFunction()
JSTypeFunctionType that is an ordinary function or
a named type that points to such a type.isOrdinaryFunction in class JSTypepublic boolean makesStructs()
public boolean makesDicts()
public void setStruct()
public void setDict()
public FunctionType toMaybeFunctionType()
JSTypetoMaybeFunctionType in interface TypeItoMaybeFunctionType in class JSTypepublic boolean canBeCalled()
JSTypecanBeCalled in class PrototypeObjectTypetrue if this type might be callable.public boolean hasImplementedInterfaces()
public java.lang.Iterable<Node> getParameters()
public java.lang.Iterable<TypeI> getParameterTypes()
getParameterTypes in interface FunctionTypeIpublic Node getParametersNode()
public int getMinArity()
getMinArity in interface FunctionTypeIpublic int getMaxArity()
getMaxArity in interface FunctionTypeIpublic JSType getReturnType()
getReturnType in interface FunctionTypeIpublic boolean isReturnTypeInferred()
public Property getSlot(java.lang.String name)
ObjectTypegetSlot in class ObjectTypepublic java.util.Set<java.lang.String> getOwnPropertyNames()
getOwnPropertyNames in interface ObjectTypeIgetOwnPropertyNames in class ObjectTypepublic ObjectType getPrototypeProperty()
getPrototypeProperty in interface FunctionTypeIpublic ObjectType getPrototype()
prototype property of this function type. This is equivalent to (ObjectType) getPropertyType("prototype").public void setPrototypeBasedOn(ObjectType baseType)
baseType - The base type.public void extendTemplateTypeMapBasedOn(ObjectType type)
type - public boolean explicitlyImplOrExtInterface(FunctionType interfaceType)
interfaceType - the interface typepublic java.lang.Iterable<ObjectType> getAllImplementedInterfaces()
public java.util.Collection<ObjectTypeI> getAncestorInterfaces()
getAncestorInterfaces in interface FunctionTypeIpublic java.lang.Iterable<ObjectType> getImplementedInterfaces()
public java.lang.Iterable<ObjectType> getOwnImplementedInterfaces()
public void setImplementedInterfaces(java.util.List<ObjectType> implementedInterfaces)
public java.lang.Iterable<ObjectType> getExtendedInterfaces()
public int getExtendedInterfacesCount()
public void setExtendedInterfaces(java.util.List<ObjectType> extendedInterfaces)
public JSType getPropertyType(java.lang.String name)
ObjectTypegetPropertyType in interface ObjectTypeIgetPropertyType in class ObjectTypeUnknownType. This method never
returns null.public FunctionType getBindReturnType(int argsToBind)
If -1 is passed, then we will return a result that accepts any parameters.
public FunctionType getSuperClassConstructor()
null if
none exists.getSuperClassConstructor in interface ObjectTypeIgetSuperClassConstructor in class ObjectTypepublic ObjectType getTopMostDefiningType(java.lang.String propertyName)
public int hashCode()
hashCode in class PrototypeObjectTypepublic boolean hasEqualCallType(FunctionType otherType)
public boolean isSubtype(JSType that)
this is a subtype of that with regard to the prototype chain.isSubtype in class PrototypeObjectTypethis <: thatprotected boolean isSubtype(JSType that, com.google.javascript.rhino.jstype.JSType.ImplCache implicitImplCache, JSType.SubtypingMode subtypingMode)
JSTypeisSubtype in class PrototypeObjectTypeimplicitImplCache - a cache that records the checked
or currently checking type pairs, for example, if previous
checking found that constructor C is a subtype of interface I,
then in the cache, table key <I,C> maps to IMPLEMENT status.public <T> T visit(Visitor<T> visitor)
JSTypevisit in class ObjectTypeVisitorpublic ObjectType getInstanceType()
getInstanceType in interface FunctionTypeIjava.lang.IllegalStateException - if this function is not a constructor (see isConstructor()).public boolean hasInstanceType()
hasInstanceType in interface FunctionTypeIpublic JSType getTypeOfThis()
this in this function.getTypeOfThis in interface FunctionTypeIgetTypeOfThis in class ObjectTypepublic Node getSource()
getSource in interface FunctionTypeIpublic void setSource(Node source)
setSource in interface FunctionTypeIpublic void clearCachedValues()
ObjectTypeclearCachedValues in class ObjectTypepublic java.lang.Iterable<FunctionTypeI> getDirectSubTypes()
FunctionTypeIgetDirectSubTypes in interface FunctionTypeIpublic boolean hasCachedValues()
ObjectTypehasCachedValues in class PrototypeObjectTypepublic java.lang.String toDebugHashCodeString()
JSTypetoDebugHashCodeString in class JSTypepublic boolean hasAnyTemplateTypesInternal()
public TypeI convertMethodToFunction()
FunctionTypeIconvertMethodToFunction in interface FunctionTypeIpublic boolean hasProperties()
FunctionTypeIhasProperties in interface FunctionTypeIpublic void setImplicitMatch(boolean flag)
flag - indicates whether or not it should support SMIpublic boolean isStructuralInterface()
isStructuralInterface in interface TypeIisStructuralInterface in class JSTypepublic boolean isAbstract()
public java.util.Map<java.lang.String,JSType> getPropertyTypeMap()
getPropertyTypeMap in class ObjectTypepublic java.util.List<FunctionType> checkExtendsLoop()
public java.util.List<FunctionType> checkExtendsLoop(java.util.HashSet<FunctionType> cache, java.util.List<FunctionType> path)
public boolean acceptsArguments(java.util.List<? extends TypeI> argumentTypes)
FunctionTypeIacceptsArguments in interface FunctionTypeIpublic FunctionTypeI.Builder toBuilder()
FunctionTypeItoBuilder in interface FunctionTypeICopyright © 2009-2018 Google. All Rights Reserved.