Class FunctionType.Builder
- java.lang.Object
-
- com.google.javascript.rhino.jstype.FunctionType.Builder
-
- Enclosing class:
- FunctionType
public static final class FunctionType.Builder extends java.lang.Object
A builder class for function and arrow types.If you need to build an interface constructor, use
JSTypeRegistry.createInterfaceType(java.lang.String, com.google.javascript.rhino.Node, com.google.common.collect.ImmutableList<com.google.javascript.rhino.jstype.TemplateType>, boolean)
.- Author:
- [email protected] (Nick Santos)
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FunctionType
build()
Constructs a new function type.FunctionType
buildAndResolve()
FunctionType.Builder
copyFromOtherFunction(FunctionType otherType)
Copies all the information from another function type.FunctionType.Builder
forConstructor()
Make this a constructor.FunctionType.Builder
forInterface()
Make this an interface.FunctionType.Builder
withClosurePrimitiveId(ClosurePrimitive id)
Sets theClosurePrimitive
corresponding to this functionFunctionType.Builder
withConstructorTemplateKeys(java.lang.Iterable<TemplateType> constructorOnlyKeys)
Specifies a subset of the template keys that only apply to the constructor, and should be removed from the instance type.FunctionType.Builder
withInferredReturnType(JSType returnType)
Sets an inferred return type.FunctionType.Builder
withIsAbstract(boolean isAbstract)
Mark abstract method.FunctionType.Builder
withName(java.lang.String name)
Set the name of the function type.FunctionType.Builder
withParameters()
Set the function to take zero parameters.FunctionType.Builder
withParameters(java.util.List<FunctionType.Parameter> parameters)
Set the parameters of the function type.FunctionType.Builder
withPrototypeBasedOn(ObjectType setPrototypeBasedOn)
Set the prototype property of a constructor.FunctionType.Builder
withReturnType(JSType returnType)
Set the return type.FunctionType.Builder
withReturnType(JSType returnType, boolean inferred)
Set the return type and whether it's inferred.FunctionType.Builder
withSourceNode(Node sourceNode)
Set the source node of the function type.FunctionType.Builder
withTemplateKeys(com.google.common.collect.ImmutableList<TemplateType> templateKeys)
Set the template name.FunctionType.Builder
withTemplateKeys(TemplateType... templateKeys)
Set the template name.FunctionType.Builder
withTypeOfThis(JSType typeOfThis)
Set the "this" type.
-
-
-
Method Detail
-
withName
public FunctionType.Builder withName(java.lang.String name)
Set the name of the function type.
-
withSourceNode
public FunctionType.Builder withSourceNode(Node sourceNode)
Set the source node of the function type.
-
withParameters
public FunctionType.Builder withParameters(java.util.List<FunctionType.Parameter> parameters)
Set the parameters of the function type.
-
withParameters
public FunctionType.Builder withParameters()
Set the function to take zero parameters.
-
withReturnType
public FunctionType.Builder withReturnType(JSType returnType)
Set the return type.
-
withReturnType
public FunctionType.Builder withReturnType(JSType returnType, boolean inferred)
Set the return type and whether it's inferred.
-
withInferredReturnType
public FunctionType.Builder withInferredReturnType(JSType returnType)
Sets an inferred return type.
-
withTypeOfThis
public FunctionType.Builder withTypeOfThis(JSType typeOfThis)
Set the "this" type.
-
withTemplateKeys
public FunctionType.Builder withTemplateKeys(com.google.common.collect.ImmutableList<TemplateType> templateKeys)
Set the template name.
-
withTemplateKeys
public FunctionType.Builder withTemplateKeys(TemplateType... templateKeys)
Set the template name.
-
withConstructorTemplateKeys
public FunctionType.Builder withConstructorTemplateKeys(java.lang.Iterable<TemplateType> constructorOnlyKeys)
Specifies a subset of the template keys that only apply to the constructor, and should be removed from the instance type. These keys must still be passed towithTemplateKeys(com.google.common.collect.ImmutableList<com.google.javascript.rhino.jstype.TemplateType>)
.
-
forConstructor
public FunctionType.Builder forConstructor()
Make this a constructor.
-
forInterface
public FunctionType.Builder forInterface()
Make this an interface.
-
withIsAbstract
public FunctionType.Builder withIsAbstract(boolean isAbstract)
Mark abstract method.
-
withPrototypeBasedOn
public FunctionType.Builder withPrototypeBasedOn(ObjectType setPrototypeBasedOn)
Set the prototype property of a constructor.
-
withClosurePrimitiveId
public FunctionType.Builder withClosurePrimitiveId(ClosurePrimitive id)
Sets theClosurePrimitive
corresponding to this function
-
copyFromOtherFunction
public FunctionType.Builder copyFromOtherFunction(FunctionType otherType)
Copies all the information from another function type.
-
build
public FunctionType build()
Constructs a new function type.
-
buildAndResolve
public FunctionType buildAndResolve()
-
-