Package de.monticore.types.check
Class SymTypeExpressionFactory
java.lang.Object
de.monticore.types.check.SymTypeExpressionFactory
SymTypeExpressionFactory contains static functions that create
the various forms of TypeExpressions used for Sym-Types.
This factory therefore should be the only source to create SymTypeExpressions. No other source is needed. (That is ok, as the set of SymTypeExpressions is rather fixed and we do not expect many modular extensions that would be needed. Saying this, we know that potentially union types (A|B) might still be added in the future.)
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static SymTypeExpressioncreateArrayFromString(String type, IBasicSymbolsScope scope) Deprecated, for removal: This API element is subject to removal in a future version.static SymTypeExpressionstatic SymTypeExpressioncreateFromSymbol(TypeSymbol typeSymbol) Warning: usually not what you want, except when resolving, consider usingWithinScopeBasicSymbolsResolver.resolveType(IBasicSymbolsScope, String),WithinTypeBasicSymbolsResolver.resolveType(SymTypeExpression, String, de.monticore.symboltable.modifiers.AccessModifier, java.util.function.Predicate), or other methods of this class whenever appropriatestatic SymTypeOfFunctioncreateFunction(FunctionSymbol symbol) static SymTypeOfFunctioncreateFunction(FunctionSymbol symbol, SymTypeExpression returnType, List<? extends SymTypeExpression> argumentTypes, boolean elliptic) static SymTypeOfFunctioncreateFunction(SymTypeExpression returnType) static SymTypeOfFunctioncreateFunction(SymTypeExpression returnType, SymTypeExpression... argumentTypes) static SymTypeOfFunctioncreateFunction(SymTypeExpression returnType, List<? extends SymTypeExpression> argumentTypes) static SymTypeOfFunctioncreateFunction(SymTypeExpression returnType, List<? extends SymTypeExpression> argumentTypes, boolean elliptic) static SymTypeOfGenericscreateGenerics(TypeSymbol typeSymbol) Deprecated, for removal: This API element is subject to removal in a future version.bad name, tends to be misused, s.a.static SymTypeOfGenericscreateGenerics(TypeSymbol typeSymbol, SymTypeExpression... arguments) static SymTypeOfGenericscreateGenerics(TypeSymbol typeSymbol, List<SymTypeExpression> arguments) static SymTypeOfGenericscreateGenerics(String name, IBasicSymbolsScope enclosingScope) Deprecated, for removal: This API element is subject to removal in a future version.hides surrogate usage, see other `createGenerics`-methodsstatic SymTypeOfGenericscreateGenerics(String name, IBasicSymbolsScope enclosingScope, SymTypeExpression... arguments) Deprecated, for removal: This API element is subject to removal in a future version.hides surrogate usage, see other `createGenerics`-methodsstatic SymTypeOfGenericscreateGenerics(String name, IBasicSymbolsScope enclosingScope, List<SymTypeExpression> arguments) Deprecated, for removal: This API element is subject to removal in a future version.hides surrogate usage, see other `createGenerics`-methodsstatic SymTypeOfGenericscreateGenericsDeclaredType(TypeSymbol typeSymbol) Hint: this is usually(!) not what you want, s.a.protected static SymTypeExpressioncreateGenericsFromString(String type, IBasicSymbolsScope scope) Deprecated, for removal: This API element is subject to removal in a future version.static SymTypeInferenceVariableUsed to create a (optionally bounded) FREE type variable, without bounds.static SymTypeInferenceVariablecreateInferenceVariable(SymTypeExpression lowerBound, SymTypeExpression upperBound) used to create a (optionally bounded) FREE type variable.static SymTypeInferenceVariablecreateInferenceVariable(SymTypeExpression lowerBound, SymTypeExpression upperBound, String idStr) Creates FREE type variable, BUT: You most likely do not want this method.static SymTypeInferenceVariablecreateInferenceVariable(SymTypeExpression lowerBound, SymTypeExpression upperBound, String idStr, int id) Only used for deepcloning: You most likely do not want this method.static SymTypeOfIntersectioncreateIntersection(SymTypeExpression... intersectedTypes) static SymTypeOfIntersectioncreateIntersection(Collection<? extends SymTypeExpression> intersectedTypes) static SymTypeExpressioncreateIntersectionOrDefault(SymTypeExpression defaultType, Collection<? extends SymTypeExpression> intersectedTypes) a slightly normalizingcreateIntersection(Collection)static SymTypeOfNumericWithSIUnitcreateNumericWithSIUnit(SymTypeOfSIUnit siUnitType, SymTypeExpression numericType) static SymTypeOfNumericWithSIUnitcreateNumericWithSIUnit(List<SIUnitBasic> numerator, List<SIUnitBasic> denominator, SymTypeExpression numericType) static SymTypeObscurestatic SymTypePrimitivecreatePrimitive(TypeSymbol type) static SymTypePrimitivecreatePrimitive(String name) for primitives, such as "int" (and no other kinds).static SymTypeOfSIUnitcreateSIUnit(List<SIUnitBasic> numerator, List<SIUnitBasic> denominator) static SIUnitBasiccreateSIUnitBasic(String dimension) static SIUnitBasiccreateSIUnitBasic(String dimension, int exponent) static SIUnitBasiccreateSIUnitBasic(String dimension, String prefix, int exponent) static SymTypeOfObjectstatic SymTypeExpressionstatic SymTypeOfTuplecreateTuple(SymTypeExpression... types) static SymTypeOfTuplecreateTuple(List<? extends SymTypeExpression> types) static SymTypeArraycreateTypeArray(TypeSymbol typeSymbol, int dim, SymTypeExpression argument) Deprecated, for removal: This API element is subject to removal in a future version.arrays do not have a type symbol usecreateTypeArray(SymTypeExpression, int)static SymTypeArraycreateTypeArray(SymTypeExpression argument, int dim) static SymTypeArraycreateTypeArray(String name, IBasicSymbolsScope typeSymbolsScope, int dim, SymTypeExpression argument) Deprecated, for removal: This API element is subject to removal in a future version.arrays do not have a name usecreateTypeArray(SymTypeExpression, int)static SymTypeExpressioncreateTypeExpression(TypeSymbol typeSymbol) Deprecated, for removal: This API element is subject to removal in a future version.misused all the time, bad name; More often than not, one does not create a SymTypeExpression based solely on a symbol, consider either usingTypeCheck3.symTypeFromAST(de.monticore.types.mcbasictypes._ast.ASTMCType),WithinScopeBasicSymbolsResolver.resolveType(IBasicSymbolsScope, String), or any other method in this class.static SymTypeExpressioncreateTypeExpression(String name, IBasicSymbolsScope scope) Deprecated, for removal: This API element is subject to removal in a future version.use TypeCheck to get SymTypeExpressions from MCTypes, this method is rather incorrect/incompletestatic SymTypeOfObjectcreateTypeObject(TypeSymbol typeSymbol) for ObjectTypes, as e.g.static SymTypeOfObjectcreateTypeObject(String name, IBasicSymbolsScope enclosingScope) Deprecated, for removal: This API element is subject to removal in a future version.did hide the usage of surrogate, and leads to questionable code consider usingWithinScopeBasicSymbolsResolver.resolveType(IBasicSymbolsScope, String), of creating a Surrogate explicitly (only if required)static SymTypeOfObjectcreateTypeObjectViaSurrogate(String name, IBasicSymbolsScope enclosingScope) Deprecated.most current usages are wrong and have to be changed in the future! Currently considered to be removed, unless this functionality is required often enough (alternative: explicitly create a Surrogate and callcreateTypeObject(TypeSymbol))static SymTypeOfNullThat is the pseudo-type of "null"static SymTypeOfRegExcreateTypeRegEx(String regex) for RegEx-types, e.g.static SymTypeVariablecreateTypeVariable(TypeSymbol typeSymbol) Deprecated, for removal: This API element is subject to removal in a future version.ALWAYS use TypeVarSymbols to create TypeVariablesstatic SymTypeVariablecreateTypeVariable(TypeVarSymbol typeVarSymbol) static SymTypeVariablecreateTypeVariable(String name, IBasicSymbolsScope scope) Deprecated, for removal: This API element is subject to removal in a future version.create a symbol and use it to create a SymTypeVariablecreateTypeVariable(TypeVarSymbol)static SymTypeVoidcreates the "Void"-type, i.e.static SymTypeOfUnioncreateUnion(SymTypeExpression... unionizedTypes) static SymTypeOfUnioncreateUnion(Collection<? extends SymTypeExpression> unionizedTypes) static SymTypeExpressioncreateUnionOrDefault(SymTypeExpression defaultType, Collection<? extends SymTypeExpression> unionizedTypes) a slightly normalizingcreateUnion(Collection)static SymTypeOfWildcardstatic SymTypeOfWildcardcreateWildcard(boolean isUpper, SymTypeExpression bound) protected static List<SymTypeExpression> getSubGenerics(List<String> inBrackets, IBasicSymbolsScope scope) Deprecated, for removal: This API element is subject to removal in a future version.iterateBrackets(String type, int start) Deprecated, for removal: This API element is subject to removal in a future version.
-
Field Details
-
LOG_NAME
- See Also:
-
-
Constructor Details
-
SymTypeExpressionFactory
public SymTypeExpressionFactory()
-
-
Method Details
-
createTypeVariable
@Deprecated(forRemoval=true) public static SymTypeVariable createTypeVariable(String name, IBasicSymbolsScope scope) Deprecated, for removal: This API element is subject to removal in a future version.create a symbol and use it to create a SymTypeVariablecreateTypeVariable(TypeVarSymbol)createTypeVariable vor Variables -
createTypeVariable
-
createTypeVariable
@Deprecated(forRemoval=true) public static SymTypeVariable createTypeVariable(TypeSymbol typeSymbol) Deprecated, for removal: This API element is subject to removal in a future version.ALWAYS use TypeVarSymbols to create TypeVariables -
createInferenceVariable
Used to create a (optionally bounded) FREE type variable, without bounds. These are created internally while inferring types. -
createInferenceVariable
public static SymTypeInferenceVariable createInferenceVariable(SymTypeExpression lowerBound, SymTypeExpression upperBound) used to create a (optionally bounded) FREE type variable. These are created internally while inferring types.- Parameters:
lowerBound- is required to be a sub-type. For no bounds usecreateBottomType().upperBound- is required to be a super-type, e.g.,T extends Person & Iterable<Integer>. For no bounds usecreateTopType().
-
createInferenceVariable
public static SymTypeInferenceVariable createInferenceVariable(SymTypeExpression lowerBound, SymTypeExpression upperBound, String idStr) Creates FREE type variable, BUT: You most likely do not want this method. UsecreateInferenceVariable(SymTypeExpression, SymTypeExpression). -
createInferenceVariable
public static SymTypeInferenceVariable createInferenceVariable(SymTypeExpression lowerBound, SymTypeExpression upperBound, String idStr, int id) Only used for deepcloning: You most likely do not want this method. UsecreateInferenceVariable(SymTypeExpression, SymTypeExpression). -
createPrimitive
for primitives, such as "int" (and no other kinds). TypeInfo is not needed (as the Objects are predefined singletons) -
createPrimitive
-
createTypeObject
for ObjectTypes, as e.g. "Person" -
createTypeObject
@Deprecated(forRemoval=true) public static SymTypeOfObject createTypeObject(String name, IBasicSymbolsScope enclosingScope) Deprecated, for removal: This API element is subject to removal in a future version.did hide the usage of surrogate, and leads to questionable code consider usingWithinScopeBasicSymbolsResolver.resolveType(IBasicSymbolsScope, String), of creating a Surrogate explicitly (only if required) -
createTypeObjectViaSurrogate
@Deprecated public static SymTypeOfObject createTypeObjectViaSurrogate(String name, IBasicSymbolsScope enclosingScope) Deprecated.most current usages are wrong and have to be changed in the future! Currently considered to be removed, unless this functionality is required often enough (alternative: explicitly create a Surrogate and callcreateTypeObject(TypeSymbol))Warn: most of the time, you don't want this, as Surrogates should be avoided creates a TypeSymbolSurrogate and a SymTypeOfObject based on the surrogate -
createTypeRegEx
for RegEx-types, e.g. 'R"gr(a|e)y"' -
createTypeVoid
creates the "Void"-type, i.e. a pseudotype that represents the absence of a real type- Returns:
-
createObscureType
-
createTypeOfNull
That is the pseudo-type of "null" -
createTypeArray
@Deprecated(forRemoval=true) public static SymTypeArray createTypeArray(TypeSymbol typeSymbol, int dim, SymTypeExpression argument) Deprecated, for removal: This API element is subject to removal in a future version.arrays do not have a type symbol usecreateTypeArray(SymTypeExpression, int)creates an array-Type Expression- Parameters:
typeSymbol-dim- the dimension of the arrayargument- the argument type (of the elements)- Returns:
-
createTypeArray
@Deprecated(forRemoval=true) public static SymTypeArray createTypeArray(String name, IBasicSymbolsScope typeSymbolsScope, int dim, SymTypeExpression argument) Deprecated, for removal: This API element is subject to removal in a future version.arrays do not have a name usecreateTypeArray(SymTypeExpression, int) -
createTypeArray
-
createTypeExpression
@Deprecated(forRemoval=true) public static SymTypeExpression createTypeExpression(TypeSymbol typeSymbol) Deprecated, for removal: This API element is subject to removal in a future version.misused all the time, bad name; More often than not, one does not create a SymTypeExpression based solely on a symbol, consider either usingTypeCheck3.symTypeFromAST(de.monticore.types.mcbasictypes._ast.ASTMCType),WithinScopeBasicSymbolsResolver.resolveType(IBasicSymbolsScope, String), or any other method in this class. -
createTypeExpression
@Deprecated(forRemoval=true) public static SymTypeExpression createTypeExpression(String name, IBasicSymbolsScope scope) Deprecated, for removal: This API element is subject to removal in a future version.use TypeCheck to get SymTypeExpressions from MCTypes, this method is rather incorrect/incompletecreates a TypeExpression for primitives, such as "int", for "null", "void" and also for object types, such as "Person" from a given symbol Primitives don't need a type symbol, object types need both.- Parameters:
name-scope-
-
createArrayFromString
@Deprecated(forRemoval=true) protected static SymTypeExpression createArrayFromString(String type, IBasicSymbolsScope scope) Deprecated, for removal: This API element is subject to removal in a future version. -
createGenericsFromString
@Deprecated(forRemoval=true) protected static SymTypeExpression createGenericsFromString(String type, IBasicSymbolsScope scope) Deprecated, for removal: This API element is subject to removal in a future version. -
getSubGenerics
@Deprecated(forRemoval=true) protected static List<SymTypeExpression> getSubGenerics(List<String> inBrackets, IBasicSymbolsScope scope) Deprecated, for removal: This API element is subject to removal in a future version.recursively callscreateGenericsFromString(String, IBasicSymbolsScope)(String, IBasicSymbolsScope)}. If that method for example receivedMap<String, List<String>>this Method should get[String, List<String>]as parameter- Parameters:
inBrackets- list of generics nested one level
-
iterateBrackets
Deprecated, for removal: This API element is subject to removal in a future version.splits the type-string along commas, but only on such that are on the first depth of generics- Parameters:
type- type-string, likeMap<Double, LinkedHashMap<String, Integer>>start- first occurrence of an opening generic- Returns:
- all first sub-generics as a list, like
[Double; LinkedHashMap<String, Integer>]
-
createGenericsDeclaredType
Hint: this is usually(!) not what you want, s.a.createGenerics(TypeSymbol, List)- Returns:
- the declared type, e.g.,
Map<K,V>, with K and V being (bound) TypeVariables
-
createGenerics
Deprecated, for removal: This API element is subject to removal in a future version.bad name, tends to be misused, s.a.createGenericsDeclaredType(TypeSymbol) -
createGenerics
public static SymTypeOfGenerics createGenerics(TypeSymbol typeSymbol, List<SymTypeExpression> arguments) -
createGenerics
public static SymTypeOfGenerics createGenerics(TypeSymbol typeSymbol, SymTypeExpression... arguments) -
createGenerics
@Deprecated(forRemoval=true) public static SymTypeOfGenerics createGenerics(String name, IBasicSymbolsScope enclosingScope) Deprecated, for removal: This API element is subject to removal in a future version.hides surrogate usage, see other `createGenerics`-methodscreateGenerics: is created using the enclosing Scope to ask for the appropriate symbol. -
createGenerics
@Deprecated(forRemoval=true) public static SymTypeOfGenerics createGenerics(String name, IBasicSymbolsScope enclosingScope, List<SymTypeExpression> arguments) Deprecated, for removal: This API element is subject to removal in a future version.hides surrogate usage, see other `createGenerics`-methods -
createGenerics
@Deprecated(forRemoval=true) public static SymTypeOfGenerics createGenerics(String name, IBasicSymbolsScope enclosingScope, SymTypeExpression... arguments) Deprecated, for removal: This API element is subject to removal in a future version.hides surrogate usage, see other `createGenerics`-methods -
createFromSymbol
Warning: usually not what you want, except when resolving, consider usingWithinScopeBasicSymbolsResolver.resolveType(IBasicSymbolsScope, String),WithinTypeBasicSymbolsResolver.resolveType(SymTypeExpression, String, de.monticore.symboltable.modifiers.AccessModifier, java.util.function.Predicate), or other methods of this class whenever appropriate -
createWildcard
-
createWildcard
-
createFunction
-
createFunction
-
createFunction
public static SymTypeOfFunction createFunction(SymTypeExpression returnType, List<? extends SymTypeExpression> argumentTypes) -
createFunction
public static SymTypeOfFunction createFunction(SymTypeExpression returnType, SymTypeExpression... argumentTypes) -
createFunction
public static SymTypeOfFunction createFunction(SymTypeExpression returnType, List<? extends SymTypeExpression> argumentTypes, boolean elliptic) -
createFunction
public static SymTypeOfFunction createFunction(FunctionSymbol symbol, SymTypeExpression returnType, List<? extends SymTypeExpression> argumentTypes, boolean elliptic) -
createSIUnitBasic
-
createSIUnitBasic
-
createSIUnitBasic
-
createSIUnit
public static SymTypeOfSIUnit createSIUnit(List<SIUnitBasic> numerator, List<SIUnitBasic> denominator) -
createNumericWithSIUnit
public static SymTypeOfNumericWithSIUnit createNumericWithSIUnit(List<SIUnitBasic> numerator, List<SIUnitBasic> denominator, SymTypeExpression numericType) -
createNumericWithSIUnit
public static SymTypeOfNumericWithSIUnit createNumericWithSIUnit(SymTypeOfSIUnit siUnitType, SymTypeExpression numericType) -
createTuple
-
createTuple
-
createUnion
-
createUnion
-
createUnionOrDefault
public static SymTypeExpression createUnionOrDefault(SymTypeExpression defaultType, Collection<? extends SymTypeExpression> unionizedTypes) a slightly normalizingcreateUnion(Collection) -
createIntersection
public static SymTypeOfIntersection createIntersection(Collection<? extends SymTypeExpression> intersectedTypes) -
createIntersection
-
createIntersectionOrDefault
public static SymTypeExpression createIntersectionOrDefault(SymTypeExpression defaultType, Collection<? extends SymTypeExpression> intersectedTypes) a slightly normalizingcreateIntersection(Collection) -
createTopType
- Returns:
- a type which is the superType of ALL other types, NO further guarantees are made. Note, this is not the case for, e.g., Java's Object class as it is not a superType of primitives This is used internally in the TypeCheck.
-
createBottomType
- Returns:
- a type which is the subType of ALL other types, NO further guarantees are made. Note, this is not the case for, e.g., Java's null type as it is not a subType of primitives This is used internally in the TypeCheck.
-
createStringType
-