Class ExpressionTranslator<I extends net.ssehub.easy.instantiation.core.model.common.VariableDeclaration,R extends net.ssehub.easy.instantiation.core.model.expressions.Resolver<I>,E extends net.ssehub.easy.instantiation.core.model.common.ExpressionStatement>
java.lang.Object
net.ssehub.easy.dslCore.translation.MessageReceiver
net.ssehub.easy.dslCore.translation.ExpressionTranslator
de.uni_hildesheim.sse.vil.expressions.translation.ExpressionTranslator<I,R,E>
- All Implemented Interfaces:
net.ssehub.easy.dslCore.translation.IMessageReceiver,net.ssehub.easy.instantiation.core.model.expressions.ResolutionListener,net.ssehub.easy.instantiation.core.model.expressions.StringResolver.IExpressionTranslator<I,R>
public abstract class ExpressionTranslator<I extends net.ssehub.easy.instantiation.core.model.common.VariableDeclaration,R extends net.ssehub.easy.instantiation.core.model.expressions.Resolver<I>,E extends net.ssehub.easy.instantiation.core.model.common.ExpressionStatement>
extends net.ssehub.easy.dslCore.translation.ExpressionTranslator
implements net.ssehub.easy.instantiation.core.model.expressions.ResolutionListener, net.ssehub.easy.instantiation.core.model.expressions.StringResolver.IExpressionTranslator<I,R>
Implements the translation from the expression DSL to the expression model in the instantiator core.
- Author:
- Holger Eichelberger
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static enumDefines basic VIL call types. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate IvmlMessageAdapterprivate net.ssehub.easy.instantiation.core.model.expressions.VarModelIdentifierExpression -
Constructor Summary
ConstructorsConstructorDescriptionCreates an expression translator (to be used within this package only). -
Method Summary
Modifier and TypeMethodDescriptionnet.ssehub.easy.instantiation.core.model.expressions.ExpressionassertBooleanExpression(net.ssehub.easy.instantiation.core.model.expressions.Expression expression, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causingFeature) Asserts the given expression to be of Boolean type.protected abstract StringA hint if an assignment is not allowed.protected net.ssehub.easy.instantiation.core.model.expressions.AbstractCallExpressioncheckCallExpression(net.ssehub.easy.instantiation.core.model.expressions.AbstractCallExpression callEx, ExpressionTranslator.CallType type, Call call) Performs generic call expression checks after creation.private voidcheckOclEnumCompliance(String name, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causeFeature) Checks the given enumeration literal name for OCL compliance.protected net.ssehub.easy.instantiation.core.model.common.VilExceptioncheckSemantics(net.ssehub.easy.instantiation.core.model.expressions.Expression expr) Checks the semantics of a potential call candidate.protected booleancontinueResolution(net.ssehub.easy.instantiation.core.model.common.VilException semanticException) Returns whether resolution shall be continued in case of multiple similar call expressions.private net.ssehub.easy.instantiation.core.model.expressions.ExpressionconvertToVersion(String text, Constant arg, R resolver) protected static final net.ssehub.easy.instantiation.core.model.expressions.ExpressioncreateConstant(net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> type, Object value, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causingFeature, net.ssehub.easy.instantiation.core.model.vilTypes.TypeRegistry registry) Creates a constant.protected abstract EcreateExpressionStatement(net.ssehub.easy.instantiation.core.model.expressions.Expression expression, R resolver) Creates an expression statement.protected abstract net.ssehub.easy.instantiation.core.model.expressions.ExpressionVersionRestrictioncreateExpressionVersionRestriction(net.ssehub.easy.instantiation.core.model.expressions.Expression expr, net.ssehub.easy.instantiation.core.model.common.VariableDeclaration decl, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature feature) Creates an expression version restriction matching this class.protected abstract IcreateImplicitVariableDeclaration(String name, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> type, boolean isConstant, net.ssehub.easy.instantiation.core.model.expressions.Expression expression, R resolver) Creates a new implicit variable declaration.protected abstract IcreateVariableDeclaration(String name, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> type, boolean isConstant, net.ssehub.easy.instantiation.core.model.expressions.Expression expression, R resolver) Creates a new variable declaration.voidEnacts the IVML warnings not resolved by "function pointers" so far.voiderror(net.ssehub.easy.basics.messages.AbstractException exception, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causeFeature) Turns a buildlang exception into a xText error.Returns the IVML message adapter.private static StringgetName(org.eclipse.emf.ecore.EObject cause) Tries to obtain the name ofcause.private voidivmlWarning(String name, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causingFeature) Creates a warning due to an unresolved IVML element.private net.ssehub.easy.instantiation.core.model.expressions.ExpressionnormalizeStringExpression(net.ssehub.easy.instantiation.core.model.expressions.Expression ex, String st) Normalizes a string expression, i.e., ifex(within aCompositeExpressionis not a constant, aStringExpressioncontaining the expression is inserted instead.abstract net.ssehub.easy.instantiation.core.model.expressions.ExpressionparseExpression(String expression, R resolver, StringBuilder warnings) Parse the given expression.private net.ssehub.easy.instantiation.core.model.expressions.FieldAccessExpressionprocess(net.ssehub.easy.instantiation.core.model.common.VariableDeclaration var, net.ssehub.easy.instantiation.core.model.expressions.FieldAccessExpression last, String name, Constant elt) protected net.ssehub.easy.instantiation.core.model.expressions.ExpressionprocessAdditiveExpression(AdditiveExpression ex, R resolver) Processes an additive expression.net.ssehub.easy.instantiation.core.model.expressions.CallArgument[]processArguments(ArgumentList arguments, R resolver) Processes an argument list and translates them into call arguments.net.ssehub.easy.instantiation.core.model.expressions.ExpressionprocessAssignment(org.eclipse.emf.ecore.EObject cause, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> type, Expression ex, R resolver) Processes an assignment.protected abstract net.ssehub.easy.instantiation.core.model.expressions.ExpressionprocessCall(net.ssehub.easy.instantiation.core.model.expressions.Expression firstParam, Call call, ExpressionTranslator.CallType type, Expression arrayEx, R resolver) Processes a function call.protected net.ssehub.easy.instantiation.core.model.expressions.ExpressionprocessConstant(Constant arg, R resolver) Processes a constant argument.private net.ssehub.easy.instantiation.core.model.expressions.ContainerInitializerExpressionprocessContainerInitializer(ContainerInitializer initializer, R resolver) Processes a container initializer expression.processDeclarators(Call call, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> implicitType, List<net.ssehub.easy.instantiation.core.model.expressions.CallArgument> arguments, R resolver) Processes a declarator.protected net.ssehub.easy.instantiation.core.model.expressions.ExpressionprocessEqualityExpression(EqualityExpression ex, R resolver) Processes an equality expression.net.ssehub.easy.instantiation.core.model.expressions.ExpressionprocessExpression(Expression ex, R resolver) Creates the expression tree for a given expression.processExpressionStatement(ExpressionStatement expr, R resolver) Processes an expression statement.net.ssehub.easy.instantiation.core.model.expressions.ExpressionprocessLogicalExpression(LogicalExpression ex, R resolver) Processes a logical expression.protected net.ssehub.easy.instantiation.core.model.expressions.ExpressionprocessMultiplicativeExpression(MultiplicativeExpression ex, R resolver) Processes a multiplicative expression.protected net.ssehub.easy.instantiation.core.model.expressions.ExpressionprocessPostfixExpression(PostfixExpression ex, R resolver) Processes a postfix expression.net.ssehub.easy.instantiation.core.model.expressions.ExpressionprocessPrimaryExpression(PrimaryExpression ex, R resolver) Processes a primary expression.protected net.ssehub.easy.instantiation.core.model.expressions.ExpressionprocessQualifiedValue(String name, Constant arg, org.eclipse.emf.ecore.EStructuralFeature feature, R resolver) Processes a qualified value and creates variable expressions.protected net.ssehub.easy.instantiation.core.model.expressions.ExpressionprocessRelationalExpression(RelationalExpression ex, R resolver) Processes a relational expression.net.ssehub.easy.basics.modelManagement.IVersionRestrictionprocessRestriction(String name, VersionSpec spec, R resolver) Processes an import restriction.protected net.ssehub.easy.instantiation.core.model.expressions.ExpressionprocessSubCall(net.ssehub.easy.instantiation.core.model.expressions.Expression result, SubCall call, ExpressionTranslator.CallType callType, R resolver) Processes a single sub call, i.e., calls connected by ".".protected net.ssehub.easy.instantiation.core.model.expressions.ExpressionprocessSubCalls(net.ssehub.easy.instantiation.core.model.expressions.Expression firstParam, org.eclipse.emf.common.util.EList<SubCall> followups, R resolver) Processes sub calls, i.e., calls connected by ".".net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> processType(Type type, R resolver) Processes the given type and tries to resolve it to a VIL type.protected net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?>[]processTypeParameter(TypeParameters param, Type type, R resolver) Processes the type parameter.protected net.ssehub.easy.instantiation.core.model.expressions.ExpressionprocessUnaryExpression(UnaryExpression ex, R resolver) Processes a unary expression.processVariableDeclaration(VariableDeclaration decl, R resolver) Processes a variable declaration.voidreProcessVariableDeclaration(I decl, R resolver) Re-processes a variable declaration in order to get rid ofDeferredResolvableOperationExpression.private net.ssehub.easy.instantiation.core.model.expressions.ExpressionresolveCallArgumentExpression(NamedArgument param, int paramIndex, List<I> iterators, List<net.ssehub.easy.instantiation.core.model.expressions.CallArgument> arguments, R resolver) Tries to resolve a call argument.protected StringresolveCallArguments(Call call, List<I> iterators, List<net.ssehub.easy.instantiation.core.model.expressions.CallArgument> arguments, Expression arrayEx, R resolver) Resolves call arguments.voidresolved(net.ssehub.easy.instantiation.core.model.expressions.VarModelIdentifierExpression ex) resolveIteratorDeclarations(Call call, ExpressionTranslator.CallType type, List<net.ssehub.easy.instantiation.core.model.expressions.CallArgument> arguments, R resolver) Resolves the iterator declarations.private net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> resolveModelType(Type type, String typeName, R resolver) Resolves a model type.setIvmlMessageAdapter(IvmlMessageAdapter adapter) Allows for (temporary) exchange of the IVML message adapter, e.g., to handle warnings differently.private voidthrowVariableCannotBeInitialized(org.eclipse.emf.ecore.EObject cause, String name, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> declType, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> initType) Throws aTranslatorExceptionthat a variable cannot be initialized.private net.ssehub.easy.instantiation.core.model.expressions.ExpressionEvaluatortryIteratorExpression(List<net.ssehub.easy.instantiation.core.model.expressions.CallArgument> arguments, NamedArgument param, R resolver) Tries to compose an iterator expression (ExpressionEvaluator)voidwarning(net.ssehub.easy.basics.messages.AbstractException exception, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causeFeature) Turns a buildlang exception into a xText warning.voidIssues implementation warnings about version restrictions.Methods inherited from class net.ssehub.easy.dslCore.translation.ExpressionTranslator
addMessage, clearMessages, clearMessages, collect, error, error, getErrorCount, getMessage, getMessageCount, warningMethods inherited from class net.ssehub.easy.dslCore.translation.MessageReceiver
error
-
Field Details
-
lastVarModelIdentifierEx
private net.ssehub.easy.instantiation.core.model.expressions.VarModelIdentifierExpression lastVarModelIdentifierEx -
ivmlMessageAdapter
-
-
Constructor Details
-
ExpressionTranslator
public ExpressionTranslator()Creates an expression translator (to be used within this package only).
-
-
Method Details
-
setIvmlMessageAdapter
Allows for (temporary) exchange of the IVML message adapter, e.g., to handle warnings differently.- Parameters:
adapter- the new message adapter- Returns:
- the old message adapter
-
getIvmlMessageAdapter
Returns the IVML message adapter.- Returns:
- the adapter instance
-
processExpression
public net.ssehub.easy.instantiation.core.model.expressions.Expression processExpression(Expression ex, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Creates the expression tree for a given expression.- Parameters:
ex- the expression to be processedresolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression tree
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails for some reason
-
enactIvmlWarnings
public void enactIvmlWarnings()Enacts the IVML warnings not resolved by "function pointers" so far. -
ivmlWarning
private void ivmlWarning(String name, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causingFeature) Creates a warning due to an unresolved IVML element.- Parameters:
name- the name of the elementcause- the causing ECore elementcausingFeature- the causing ECore feature
-
processExpressionStatement
public E processExpressionStatement(ExpressionStatement expr, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes an expression statement.- Parameters:
expr- the expression to be processedresolver- a resolver instance for resolving variables etc.- Returns:
- the expression statement
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails due to semantic reasons- See Also:
-
cannotAssignHint
A hint if an assignment is not allowed.- Returns:
- the hint (must not be null)
-
createExpressionStatement
protected abstract E createExpressionStatement(net.ssehub.easy.instantiation.core.model.expressions.Expression expression, R resolver) Creates an expression statement.- Parameters:
expression- the expressionresolver- the resolver instance- Returns:
- the expression statement
-
processLogicalExpression
public net.ssehub.easy.instantiation.core.model.expressions.Expression processLogicalExpression(LogicalExpression ex, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes a logical expression.- Parameters:
ex- the expression to be processedresolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression node
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails for some reason
-
processEqualityExpression
protected net.ssehub.easy.instantiation.core.model.expressions.Expression processEqualityExpression(EqualityExpression ex, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes an equality expression.- Parameters:
ex- the expression to be processedresolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression node
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails for some reason
-
processRelationalExpression
protected net.ssehub.easy.instantiation.core.model.expressions.Expression processRelationalExpression(RelationalExpression ex, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes a relational expression.- Parameters:
ex- the expression to be processedresolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression node
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails for some reason
-
processAdditiveExpression
protected net.ssehub.easy.instantiation.core.model.expressions.Expression processAdditiveExpression(AdditiveExpression ex, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes an additive expression.- Parameters:
ex- the expression to be processedresolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression node
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails for some reason
-
processMultiplicativeExpression
protected net.ssehub.easy.instantiation.core.model.expressions.Expression processMultiplicativeExpression(MultiplicativeExpression ex, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes a multiplicative expression.- Parameters:
ex- the expression to be processedresolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression node
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails for some reason
-
processUnaryExpression
protected net.ssehub.easy.instantiation.core.model.expressions.Expression processUnaryExpression(UnaryExpression ex, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes a unary expression.- Parameters:
ex- the expression to be processedresolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression node
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails for some reason
-
processPostfixExpression
protected net.ssehub.easy.instantiation.core.model.expressions.Expression processPostfixExpression(PostfixExpression ex, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes a postfix expression.- Parameters:
ex- the expression to be processedresolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression node
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails for some reason
-
resolveIteratorDeclarations
protected List<I> resolveIteratorDeclarations(Call call, ExpressionTranslator.CallType type, List<net.ssehub.easy.instantiation.core.model.expressions.CallArgument> arguments, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Resolves the iterator declarations. Existence of iterator declarations incallis already checked to be valid.- Parameters:
call- the call holding the iterator declarationstype- the type of the call (not the return type)- Returns:
- the iterator declarations in terms of variable declarations (may be empty if there are none)
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails for some reason
-
processDeclarators
private ArrayList<I> processDeclarators(Call call, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> implicitType, List<net.ssehub.easy.instantiation.core.model.expressions.CallArgument> arguments, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes a declarator.- Parameters:
call- the actual callimplicitType- the implicit type of the declarator to check against or to use if no explicit type is given, may be null if the underlying type declares the collection implicitly (see deleteJavaCall). In the latter case, the type must be explicitly given by the declarator.arguments- the call arguments (may be changed to enable implicit collection iterators)resolver- the resolver- Returns:
- a list of resolved declarators (at the moment at maximum 1)
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails
-
resolveCallArguments
protected String resolveCallArguments(Call call, List<I> iterators, List<net.ssehub.easy.instantiation.core.model.expressions.CallArgument> arguments, Expression arrayEx, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Resolves call arguments.- Parameters:
call- the call to resolve the arguments foriterators- the iterators (may be changed as a side effect)arguments- the arguments created so far (may be the operator, list is modified as a side effect)arrayEx- an array access expression (may be null, but thencallis required)resolver- a resolver instance for resolving variables etc.- Returns:
- the operation name
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails for some reason
-
resolveCallArgumentExpression
private net.ssehub.easy.instantiation.core.model.expressions.Expression resolveCallArgumentExpression(NamedArgument param, int paramIndex, List<I> iterators, List<net.ssehub.easy.instantiation.core.model.expressions.CallArgument> arguments, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Tries to resolve a call argument. If it is the first argument of a container iteration and there is no iterator, implicitly try to create an iterator.- Parameters:
param- the parameterparamIndex- the 0-based index ofparamin the call being processediterators- the iterators known so far (may be changed as a side effect)arguments- the call argumentsresolver- the resolver instance- Returns:
- the resolved expression
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that resolution fails
-
tryIteratorExpression
private net.ssehub.easy.instantiation.core.model.expressions.ExpressionEvaluator tryIteratorExpression(List<net.ssehub.easy.instantiation.core.model.expressions.CallArgument> arguments, NamedArgument param, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Tries to compose an iterator expression (ExpressionEvaluator)- Parameters:
arguments- the arguments to try to construct the expression fromparam- the actual parameter to do the resolution forresolver- a resolver instance for resolving variables etc.- Returns:
- the iterator expression if successful
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the expression cannot be created
-
createVariableDeclaration
protected abstract I createVariableDeclaration(String name, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> type, boolean isConstant, net.ssehub.easy.instantiation.core.model.expressions.Expression expression, R resolver) Creates a new variable declaration.- Parameters:
name- the name of the variabletype- the type of the variableisConstant- whether this variable is a constantexpression- an expression denoting the initial value (may be null)resolver- the resolver instance
-
createImplicitVariableDeclaration
protected abstract I createImplicitVariableDeclaration(String name, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> type, boolean isConstant, net.ssehub.easy.instantiation.core.model.expressions.Expression expression, R resolver) Creates a new implicit variable declaration.- Parameters:
name- the name of the variabletype- the type of the variableisConstant- whether this variable is a constantexpression- an expression denoting the initial value (may be null)resolver- the resolver instance
-
processCall
protected abstract net.ssehub.easy.instantiation.core.model.expressions.Expression processCall(net.ssehub.easy.instantiation.core.model.expressions.Expression firstParam, Call call, ExpressionTranslator.CallType type, Expression arrayEx, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes a function call.- Parameters:
firstParam- the first parameter (may be null)call- the function all (may be null, but thenarrayExis required)arrayEx- an array access expression (may be null, but thencallis required)resolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression node
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails for some reason
-
checkCallExpression
protected net.ssehub.easy.instantiation.core.model.expressions.AbstractCallExpression checkCallExpression(net.ssehub.easy.instantiation.core.model.expressions.AbstractCallExpression callEx, ExpressionTranslator.CallType type, Call call) throws net.ssehub.easy.dslCore.translation.TranslatorException Performs generic call expression checks after creation.- Parameters:
callEx- the call expression to be checked (may be null if not resolvable)type- the call typecall- the originating ECore call element- Returns:
callEx- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case of serious problems, e.g.,callExis null
-
checkSemantics
protected net.ssehub.easy.instantiation.core.model.common.VilException checkSemantics(net.ssehub.easy.instantiation.core.model.expressions.Expression expr) Checks the semantics of a potential call candidate.- Parameters:
expr- the expression to be checked- Returns:
- the
exprif ok or null
-
processSubCalls
protected net.ssehub.easy.instantiation.core.model.expressions.Expression processSubCalls(net.ssehub.easy.instantiation.core.model.expressions.Expression firstParam, org.eclipse.emf.common.util.EList<SubCall> followups, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes sub calls, i.e., calls connected by ".".- Parameters:
firstParam- the first parameter (the expression before the ".")followups- the follow-up callsresolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression node
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails for some reason
-
processSubCall
protected net.ssehub.easy.instantiation.core.model.expressions.Expression processSubCall(net.ssehub.easy.instantiation.core.model.expressions.Expression result, SubCall call, ExpressionTranslator.CallType callType, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes a single sub call, i.e., calls connected by ".".- Parameters:
result- the expression created so far, to connect tocall- the subCallcallType- the call typeresolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression node
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails for some reason
-
processPrimaryExpression
public net.ssehub.easy.instantiation.core.model.expressions.Expression processPrimaryExpression(PrimaryExpression ex, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes a primary expression.- Parameters:
ex- the expression to be processedresolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression node
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails for some reason
-
processArguments
public net.ssehub.easy.instantiation.core.model.expressions.CallArgument[] processArguments(ArgumentList arguments, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes an argument list and translates them into call arguments.- Parameters:
arguments- the arguments to be translatedresolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression node
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails for some reason
-
parseExpression
public abstract net.ssehub.easy.instantiation.core.model.expressions.Expression parseExpression(String expression, R resolver, StringBuilder warnings) throws net.ssehub.easy.instantiation.core.model.common.VilException Parse the given expression.- Specified by:
parseExpressionin interfacenet.ssehub.easy.instantiation.core.model.expressions.StringResolver.IExpressionTranslator<I extends net.ssehub.easy.instantiation.core.model.common.VariableDeclaration,R extends net.ssehub.easy.instantiation.core.model.expressions.Resolver<I>> - Parameters:
expression- the expression as stringresolver- the resolverwarnings- a collector for warnings- Returns:
- the resulting expression
- Throws:
net.ssehub.easy.instantiation.core.model.common.VilException- if problems occur while parsing / resolving
-
processConstant
protected net.ssehub.easy.instantiation.core.model.expressions.Expression processConstant(Constant arg, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes a constant argument.- Parameters:
arg- the constant to be processedresolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression node
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails for some reason
-
normalizeStringExpression
private net.ssehub.easy.instantiation.core.model.expressions.Expression normalizeStringExpression(net.ssehub.easy.instantiation.core.model.expressions.Expression ex, String st) throws net.ssehub.easy.instantiation.core.model.common.VilException Normalizes a string expression, i.e., ifex(within aCompositeExpressionis not a constant, aStringExpressioncontaining the expression is inserted instead. This allows recursive/nested variable/expression substitution without having the required string quotes being quoted within a string.- Parameters:
ex- the expression to check- Returns:
exor a modifiedex- Throws:
net.ssehub.easy.instantiation.core.model.common.VilException- if creating the modified expression fails
-
convertToVersion
private net.ssehub.easy.instantiation.core.model.expressions.Expression convertToVersion(String text, Constant arg, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException - Throws:
net.ssehub.easy.dslCore.translation.TranslatorException
-
process
private net.ssehub.easy.instantiation.core.model.expressions.FieldAccessExpression process(net.ssehub.easy.instantiation.core.model.common.VariableDeclaration var, net.ssehub.easy.instantiation.core.model.expressions.FieldAccessExpression last, String name, Constant elt) throws net.ssehub.easy.dslCore.translation.TranslatorException - Throws:
net.ssehub.easy.dslCore.translation.TranslatorException
-
processQualifiedValue
protected net.ssehub.easy.instantiation.core.model.expressions.Expression processQualifiedValue(String name, Constant arg, org.eclipse.emf.ecore.EStructuralFeature feature, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes a qualified value and creates variable expressions.- Parameters:
name- the qualified namearg- the constant to be processedfeature- the feature corresponding toargresolver- a resolver instance for resolving variables etc.- Returns:
- the resulting expression node
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails for some reason, in particular if ITER cannot be resolved
-
checkOclEnumCompliance
private void checkOclEnumCompliance(String name, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causeFeature) Checks the given enumeration literal name for OCL compliance.- Parameters:
name- the namecause- the causing objectcauseFeature- the causing feature
-
createConstant
protected static final net.ssehub.easy.instantiation.core.model.expressions.Expression createConstant(net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> type, Object value, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causingFeature, net.ssehub.easy.instantiation.core.model.vilTypes.TypeRegistry registry) throws net.ssehub.easy.dslCore.translation.TranslatorException Creates a constant.- Parameters:
type- the type of the constantvalue- the value of the constantcause- the Ecore language model element for which the exception was causedcausingFeature- the specific language feature withincausewhich caused the exception- Returns:
- the created constant expression
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that type resolution fails
-
processType
public net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> processType(Type type, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes the given type and tries to resolve it to a VIL type.- Parameters:
type- the type to be processedresolver- the resolver instance- Returns:
- the corresponding VIL type
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that type resolution fails
-
resolveModelType
private net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> resolveModelType(Type type, String typeName, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Resolves a model type.- Parameters:
type- the type as ECore instancetypeName- the name of the typeresolver- the resolver- Returns:
- the type or null if not resolved
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case of a serious resolution problem
-
processContainerInitializer
private net.ssehub.easy.instantiation.core.model.expressions.ContainerInitializerExpression processContainerInitializer(ContainerInitializer initializer, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes a container initializer expression.- Parameters:
initializer- the container initializer expression as ECore instanceresolver- a resolver instance for resolving variables etc.- Returns:
- the resolved container initializer expression
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that type resolution fails
-
processTypeParameter
protected net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?>[] processTypeParameter(TypeParameters param, Type type, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes the type parameter.- Parameters:
param- the ECore instance containing the type parametertype- the type the parameter are assigned toresolver- the resolver instance- Returns:
- the processed parameter in terms of VIL type descriptors
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that type resolution fails
-
processAssignment
public net.ssehub.easy.instantiation.core.model.expressions.Expression processAssignment(org.eclipse.emf.ecore.EObject cause, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> type, Expression ex, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes an assignment.- Parameters:
type- the type of the variableex- the expression defining the right side of the assignment (may be null)resolver- the resolver instancedecl- the variable declaration to assign totext- a text describing the left side in case of an error- Returns:
- the resolved initialization expression or null if
exwas null - Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that type resolution / compliance fails
-
processVariableDeclaration
public I processVariableDeclaration(VariableDeclaration decl, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes a variable declaration.- Parameters:
decl- the declarationresolver- a resolver instance for resolving variables etc.- Returns:
- the created model instance
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails
-
reProcessVariableDeclaration
public void reProcessVariableDeclaration(I decl, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Re-processes a variable declaration in order to get rid ofDeferredResolvableOperationExpression.- Parameters:
decl- the declarationresolver- the resolver- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that re-processing fails for some reason
-
throwVariableCannotBeInitialized
private void throwVariableCannotBeInitialized(org.eclipse.emf.ecore.EObject cause, String name, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> declType, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> initType) throws net.ssehub.easy.dslCore.translation.TranslatorException Throws aTranslatorExceptionthat a variable cannot be initialized.- Parameters:
cause- the causing ECore objectname- the name of the object (inferred fromcauseif null if possible)declType- the declaration VIL typeinitType- the init expression VIL type- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- the created exception
-
getName
Tries to obtain the name ofcause.- Parameters:
cause- the cause- Returns:
- the name or
"?"
-
continueResolution
protected boolean continueResolution(net.ssehub.easy.instantiation.core.model.common.VilException semanticException) Returns whether resolution shall be continued in case of multiple similar call expressions.- Parameters:
semanticException- the exception being thrown by the (partial) call resolution- Returns:
trueif resolution shall be continued (there was an exception and it points to a resolution or a semantic problem),falseelse
-
error
public void error(net.ssehub.easy.basics.messages.AbstractException exception, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causeFeature) Turns a buildlang exception into a xText error.- Parameters:
exception- the exception to usedcause- the cause (as instance of the EMF grammar model)causeFeature- the cause of the feature as an appropriate constant fromIvmlPackage.Literals
-
warning
public void warning(net.ssehub.easy.basics.messages.AbstractException exception, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causeFeature) Turns a buildlang exception into a xText warning.- Parameters:
exception- the exception to usedcause- the cause (as instance of the EMF grammar model)causeFeature- the cause of the feature as an appropriate constant fromIvmlPackage.Literals
-
warnVersionRestrictions
Issues implementation warnings about version restrictions.- Parameters:
spec- the version specification (may be null)
-
processRestriction
public net.ssehub.easy.basics.modelManagement.IVersionRestriction processRestriction(String name, VersionSpec spec, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes an import restriction.- Parameters:
name- the name of the importspec- the version specification to be processed- Returns:
- the created restriction
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case of any translation problem
-
createExpressionVersionRestriction
protected abstract net.ssehub.easy.instantiation.core.model.expressions.ExpressionVersionRestriction createExpressionVersionRestriction(net.ssehub.easy.instantiation.core.model.expressions.Expression expr, net.ssehub.easy.instantiation.core.model.common.VariableDeclaration decl, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature feature) throws net.ssehub.easy.basics.modelManagement.RestrictionEvaluationException Creates an expression version restriction matching this class.- Parameters:
expr- the expression for the restrictiondecl- the version variablecause- the grammar cause for this callfeature- the causing feature- Returns:
- the created instance
- Throws:
net.ssehub.easy.basics.modelManagement.RestrictionEvaluationException- in case of any type related problems
-
resolved
public void resolved(net.ssehub.easy.instantiation.core.model.expressions.VarModelIdentifierExpression ex) - Specified by:
resolvedin interfacenet.ssehub.easy.instantiation.core.model.expressions.ResolutionListener
-
assertBooleanExpression
public net.ssehub.easy.instantiation.core.model.expressions.Expression assertBooleanExpression(net.ssehub.easy.instantiation.core.model.expressions.Expression expression, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causingFeature) throws net.ssehub.easy.dslCore.translation.TranslatorException Asserts the given expression to be of Boolean type.- Parameters:
expression- the expression to checkcause- the causing ECore AST objectcausingFeature- the causing feature- Returns:
expressionor a converted expression- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- thrown if the expression is not of type Boolean
-