Class AbstractModelTranslator.AbstractRuleTranslator<D extends org.eclipse.emf.ecore.EObject,R extends net.ssehub.easy.instantiation.core.model.buildlangModel.Rule>
java.lang.Object
de.uni_hildesheim.sse.buildLanguageTranslation.AbstractModelTranslator.AbstractRuleTranslator<D,R>
- Type Parameters:
D- the Ecore language declaration typeR- the model rule type
- Direct Known Subclasses:
AbstractModelTranslator.RuleTranslator
- Enclosing class:
AbstractModelTranslator<M extends net.ssehub.easy.instantiation.core.model.buildlangModel.Script,L extends LanguageUnit>
protected abstract class AbstractModelTranslator.AbstractRuleTranslator<D extends org.eclipse.emf.ecore.EObject,R extends net.ssehub.easy.instantiation.core.model.buildlangModel.Rule>
extends Object
An extensible rule translator. The functions used here are more or less the same for rules as well as
later rt-VIL strategies and tactics.
- Author:
- Holger Eichelberger
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractRuleTranslator(Class<D> cls) Creates a rule translator. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidAdds the given rule to theprotected abstract RcreateRule(D ruleDecl, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> returnType, net.ssehub.easy.instantiation.core.model.buildlangModel.VariableDeclaration[] params, M parent) Creates a specific rule from the given declaration, parameters and parent.protected abstract RuleElementBlockReturns the actual rule block.protected abstract StringReturns the display name of the language concept being processed.protected abstract org.eclipse.emf.ecore.EStructuralFeatureReturns the name literal.protected abstract de.uni_hildesheim.sse.vil.expressions.expressionDsl.ParameterListgetParameterList(D ruleDecl) Returns the actual parameter list.protected org.eclipse.emf.ecore.EStructuralFeatureReturns the postcondition literal.protected org.eclipse.emf.ecore.EStructuralFeatureReturns the precondition literal.protected abstract net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> getReturnType(D ruleDecl, net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver resolver) Returns the result type of the givenruleDecl.protected abstract RuleConditionsgetRuleConditions(D ruleDecl) Returns the actual rule conditions.protected voidprocessAdditionalRuleBodyElements(D ruleDecl, R rule, M parent, net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver resolver) Is called to process additional rule body elements.processRule(D ruleDecl, M parent) Processes a rule declaration.private voidprocessRuleBody(RuleInfo<D, R> info, M parent) Processes a rule body.private voidprocessRuleConditions(net.ssehub.easy.instantiation.core.model.buildlangModel.RuleDescriptor descriptor, RuleConditions cond) Processes optional rule pre/postconditions.voidprocessRules(L unit, List<org.eclipse.emf.ecore.EObject> elements, M script) Processes all rules considering dependencies and terminates with an error if not all can be resolved.
-
Field Details
-
cls
-
-
Constructor Details
-
AbstractRuleTranslator
Creates a rule translator.- Parameters:
cls- the language declaration class
-
-
Method Details
-
processRules
public void processRules(L unit, List<org.eclipse.emf.ecore.EObject> elements, M script) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes all rules considering dependencies and terminates with an error if not all can be resolved.- Parameters:
unit- the language unit to processelements- the language elements to be processedscript- the resulting instance being created- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException
-
processRule
protected RuleInfo<D,R> processRule(D ruleDecl, M parent) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes a rule declaration.- Parameters:
ruleDecl- the ECore rule objectparent- the parent script- Returns:
- the actual rule information object linking ECore and build language instances
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails due to semantic reasons- See Also:
-
processRuleBody
private void processRuleBody(RuleInfo<D, R> info, M parent) throws net.ssehub.easy.dslCore.translation.TranslatorExceptionProcesses a rule body.- Parameters:
info- the rule information object containing the link between the ECore and the model instance- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails due to semantic reasons
-
processRuleConditions
private void processRuleConditions(net.ssehub.easy.instantiation.core.model.buildlangModel.RuleDescriptor descriptor, RuleConditions cond) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes optional rule pre/postconditions.- Parameters:
ruleDecl- the ECore rule objectparent- the parent script- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails due to semantic reasons- See Also:
-
addRule
Adds the given rule to the -
getDisplayName
Returns the display name of the language concept being processed.- Returns:
- the display name
-
getNameLiteral
protected abstract org.eclipse.emf.ecore.EStructuralFeature getNameLiteral()Returns the name literal.- Returns:
- the name literal
-
getPreconditionLiteral
protected org.eclipse.emf.ecore.EStructuralFeature getPreconditionLiteral()Returns the precondition literal.- Returns:
- the precondition literal
-
getPostconditionLiteral
protected org.eclipse.emf.ecore.EStructuralFeature getPostconditionLiteral()Returns the postcondition literal.- Returns:
- the postcondition literal
-
createRule
protected abstract R createRule(D ruleDecl, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> returnType, net.ssehub.easy.instantiation.core.model.buildlangModel.VariableDeclaration[] params, M parent) Creates a specific rule from the given declaration, parameters and parent.- Parameters:
ruleDecl- the rule declarationreturnType- the desired return typeparams- the resolved parametersparent- the parent- Returns:
- the specific rule, tactic or strategy (rt-VIL)
-
getReturnType
protected abstract net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> getReturnType(D ruleDecl, net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Returns the result type of the givenruleDecl.- Parameters:
ruleDecl- the rule declarationresolver- the actual resolver instance- Returns:
- the result type
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that resolving the type fails
-
getParameterList
protected abstract de.uni_hildesheim.sse.vil.expressions.expressionDsl.ParameterList getParameterList(D ruleDecl) Returns the actual parameter list.- Parameters:
ruleDecl- the rule declaration- Returns:
- the parameter list of the rule declaration
-
getRuleConditions
Returns the actual rule conditions.- Parameters:
ruleDecl- the rule declaration- Returns:
- the rule conditions of the rule declaration
-
processAdditionalRuleBodyElements
protected void processAdditionalRuleBodyElements(D ruleDecl, R rule, M parent, net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Is called to process additional rule body elements.- Parameters:
ruleDecl- the rule declarationrule- the actual rule (to be modified as a side effect)resolver- the variable resolver- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case of translation problems
-
getBlock
Returns the actual rule block.- Parameters:
ruleDecl- the rule declaration- Returns:
- the rule block of the rule declaration (may be null)
-