Package de.monticore.types.check
Class SymTypeOfFunction
java.lang.Object
de.monticore.types.check.SymTypeExpression
de.monticore.types.check.SymTypeOfFunction
- All Implemented Interfaces:
Comparable<SymTypeExpression>
SymTypeOfFunction stores any kind of Function,
such as
List<Person>::get, obj::<Integer>getX, i -> i + 2-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<SymTypeExpression> List of argument types of the function e.g.protected booleanWhether the function supports varargs e.g.protected Optional<FunctionSymbol> Symbol of the function may not be present (e.g., for lambdas)protected SymTypeExpressionType of return value returned when the function is calledstatic final StringDeprecated, for removal: This API element is subject to removal in a future version.only required for the deprecated type symbolFields inherited from class de.monticore.types.check.SymTypeExpression
functionList, LOG_NAME, sourceInfo, typeSymbol -
Constructor Summary
ConstructorsConstructorDescriptionSymTypeOfFunction(FunctionSymbol functionSymbol, SymTypeExpression returnType, List<? extends SymTypeExpression> argumentTypes, boolean elliptic) Constructor with all parameters that are stored: FunctionSymbol can be nullSymTypeOfFunction(SymTypeExpression returnType, List<SymTypeExpression> argumentTypes, boolean elliptic) Deprecated, for removal: This API element is subject to removal in a future version.the other constructor is to be used -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(ISymTypeVisitor visitor) booleanaddAllArgumentTypes(int index, Collection<? extends SymTypeExpression> collection) booleanaddAllArgumentTypes(Collection<? extends SymTypeExpression> collection) voidaddArgumentType(int index, SymTypeExpression element) booleanaddArgumentType(SymTypeExpression element) booleancanHaveArity(int arity) returns whether the specified amount of arguments can be accepted E.g.,(P, int...) -> intcan accept 1,2,3,...voidbooleancontainsAllArgumentTypes(Collection<?> collection) booleancontainsArgumentType(Object element) booleanbooleandeepEquals, but ignoring the return type s.a.booleanvoidforEachArgumentTypes(Consumer<? super SymTypeExpression> action) getArgumentType(int index) returns the declared typegetType()returns the type arguments for a generic function.protected Map<SymTypeVariable, SymTypeExpression> getWithFixedArity(int arity) returns a clone, with the arity fixed to the specified number E.g.,(P, int...) -> intwith arity of 3 is(P, int, int) -> intintbooleanintindexOfArgumentType(Object element) booleaniff true, the last argument type is accepted any amount of timesbooleanbooleanAm I a function type (e.g.intlastIndexOfArgumentType(Object element) listIteratorArgumentTypes(int index) booleanremoveAllArgumentTypes(Collection<?> collection) removeArgumentType(int index) booleanremoveArgumentType(Object element) booleanremoveIfArgumentType(Predicate<? super SymTypeExpression> filter) voidbooleanretainAllArgumentTypes(Collection<?> collection) setArgumentType(int index, SymTypeExpression element) voidsetArgumentTypeList(List<SymTypeExpression> argumentTypes) voidsetElliptic(boolean elliptic) intvoidsortArgumentTypes(Comparator<? super SymTypeExpression> comparator) subListArgumentTypes(int start, int end) Object[]toArrayArgumentTypes(SymTypeExpression[] array) Methods inherited from class de.monticore.types.check.SymTypeExpression
_internal_setSourceInfo, asArrayType, asGenericType, asInferenceVariable, asIntersectionType, asNullType, asNumericWithSIUnitType, asObjectType, asObscureType, asPrimitive, asRegExType, asSIUnitType, asTupleType, asTypeVariable, asUnionType, asVoidType, asWildcard, compareTo, getCorrectFields, getCorrectFields, getCorrectMethods, getCorrectMethods, getFieldList, getFieldList, getFieldList, getFieldList, getMethodList, getMethodList, getMethodList, getMethodList, getSourceInfo, getTypeInfo, hasTypeInfo, isArrayType, isGenericType, isInferenceVariable, isIntersectionType, isNullType, isNumericWithSIUnitType, isObjectType, isObscureType, isPrimitive, isRegExType, isSIUnitType, isTupleType, isTypeVariable, isUnionType, isValidType, isVoidType, isWildcard, print, printAsJson, printFullName, replaceTypeVariables, transformFieldList, transformMethodList
-
Field Details
-
TYPESYMBOL_NAME
Deprecated, for removal: This API element is subject to removal in a future version.only required for the deprecated type symbol- See Also:
-
functionSymbol
Symbol of the function may not be present (e.g., for lambdas) -
returnType
Type of return value returned when the function is called -
argumentTypes
List of argument types of the function e.g. "Integer f(Float t)" has "Float" as its argument type a this-pointer is the first argument -
elliptic
protected boolean ellipticWhether the function supports varargs e.g.Integer f(Float... t)
-
-
Constructor Details
-
SymTypeOfFunction
public SymTypeOfFunction(FunctionSymbol functionSymbol, SymTypeExpression returnType, List<? extends SymTypeExpression> argumentTypes, boolean elliptic) Constructor with all parameters that are stored: FunctionSymbol can be null -
SymTypeOfFunction
@Deprecated(forRemoval=true) public SymTypeOfFunction(SymTypeExpression returnType, List<SymTypeExpression> argumentTypes, boolean elliptic) Deprecated, for removal: This API element is subject to removal in a future version.the other constructor is to be used
-
-
Method Details
-
isFunctionType
public boolean isFunctionType()Description copied from class:SymTypeExpressionAm I a function type (e.g."String -> Integer")- Overrides:
isFunctionTypein classSymTypeExpression
-
asFunctionType
- Overrides:
asFunctionTypein classSymTypeExpression
-
deepClone
- Overrides:
deepClonein classSymTypeExpression
-
deepEquals
- Specified by:
deepEqualsin classSymTypeExpression
-
deepEqualsSignature
deepEquals, but ignoring the return type s.a. Java Spec 20 8.4.2 -
getType
- Returns:
- the return type of the function NOT the actual type of the function itself
-
isElliptic
public boolean isElliptic()iff true, the last argument type is accepted any amount of times -
setElliptic
public void setElliptic(boolean elliptic) -
hasSymbol
public boolean hasSymbol() -
getSymbol
-
canHaveArity
public boolean canHaveArity(int arity) returns whether the specified amount of arguments can be accepted E.g.,(P, int...) -> intcan accept 1,2,3,... arguments, but not 0 -
getWithFixedArity
returns a clone, with the arity fixed to the specified number E.g.,(P, int...) -> intwith arity of 3 is(P, int, int) -> int -
getDeclaredType
returns the declared type -
getTypeVariableReplaceMap
-
getTypeArguments
returns the type arguments for a generic function. E.g., given asList, which has the declared Type<T> (T...) -> List<T>and this is the instantiation(int, int) -> List<int>, This will return the argument list [int].Warning: if the instantiation is, e.g.,
(Person, Car) -> List<int>, no correct list of arguments can be calculated.Not to be confused with getArgumentTypes, which in turn returns the parameter types (a.k.a. the types the arguments need to be compatible to). Naming is confusing due to legacy reasons.
-
accept
- Overrides:
acceptin classSymTypeExpression
-
containsArgumentType
-
containsAllArgumentTypes
-
isEmptyArgumentTypes
public boolean isEmptyArgumentTypes() -
iteratorArgumentTypes
-
sizeArgumentTypes
public int sizeArgumentTypes() -
toArrayArgumentTypes
-
toArrayArgumentTypes
-
spliteratorArgumentTypes
-
streamArgumentTypes
-
parallelStreamArgumentTypes
-
getArgumentType
-
indexOfArgumentType
-
lastIndexOfArgumentType
-
equalsArgumentTypeTypes
-
hashCodeArgumentTypes
public int hashCodeArgumentTypes() -
listIteratorArgumentTypes
-
listIteratorArgumentTypes
-
subListArgumentTypes
-
getArgumentTypeList
-
clearArgumentTypes
public void clearArgumentTypes() -
addArgumentType
-
addAllArgumentTypes
-
removeArgumentType
-
removeAllArgumentTypes
-
retainAllArgumentTypes
-
removeIfArgumentType
-
forEachArgumentTypes
-
addArgumentType
-
addAllArgumentTypes
-
removeArgumentType
-
setArgumentType
-
replaceAllArgumentTypes
-
sortArgumentTypes
-
setArgumentTypeList
-