Class AbstractModelTranslator<M extends net.ssehub.easy.instantiation.core.model.buildlangModel.Script,L extends LanguageUnit>
java.lang.Object
net.ssehub.easy.dslCore.translation.MessageReceiver
net.ssehub.easy.dslCore.translation.ModelTranslator<ExpressionTranslator>
de.uni_hildesheim.sse.vil.expressions.translation.ModelTranslator<M,net.ssehub.easy.instantiation.core.model.buildlangModel.VariableDeclaration,net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver,net.ssehub.easy.instantiation.core.model.buildlangModel.ExpressionStatement,ExpressionTranslator>
de.uni_hildesheim.sse.buildLanguageTranslation.AbstractModelTranslator<M,L>
- All Implemented Interfaces:
net.ssehub.easy.dslCore.translation.IMessageReceiver
- Direct Known Subclasses:
ModelTranslator
public abstract class AbstractModelTranslator<M extends net.ssehub.easy.instantiation.core.model.buildlangModel.Script,L extends LanguageUnit>
extends de.uni_hildesheim.sse.vil.expressions.translation.ModelTranslator<M,net.ssehub.easy.instantiation.core.model.buildlangModel.VariableDeclaration,net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver,net.ssehub.easy.instantiation.core.model.buildlangModel.ExpressionStatement,ExpressionTranslator>
Implements the translation from the DSL to the build model in the instantiator core. This class is intended for
reuse.
- Author:
- Holger Eichelberger
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classAbstractModelTranslator.AbstractRuleTranslator<D extends org.eclipse.emf.ecore.EObject,R extends net.ssehub.easy.instantiation.core.model.buildlangModel.Rule> An extensible rule translator.protected classImplements a translator for VIL rules. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ExpressionTranslatorprivate net.ssehub.easy.instantiation.core.model.buildlangModel.Resolverprivate AbstractModelTranslator<M,L>.RuleTranslator -
Constructor Summary
ConstructorsModifierConstructorDescriptionCreates a model translator.protectedAbstractModelTranslator(ExpressionTranslator expressionTranslator, net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver resolver) Creates a model translator. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddVisibleDeclarationsToResolver(M model, net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver resolver) protected voidcheckConstants(net.ssehub.easy.instantiation.core.model.buildlangModel.Script project, L cause) Performs static tests on the constants.protected net.ssehub.easy.instantiation.core.model.buildlangModel.VariableDeclaration[]createArray(int len) protected net.ssehub.easy.instantiation.core.model.buildlangModel.CompoundcreateCompound(net.ssehub.easy.instantiation.core.model.vilTypes.CompoundTypeDescriptor type) protected abstract McreateScript(String name, net.ssehub.easy.basics.modelManagement.ModelImport<M> parent, net.ssehub.easy.instantiation.core.model.buildlangModel.Script.ScriptDescriptor<M> descriptor, net.ssehub.easy.instantiation.core.model.vilTypes.TypeRegistry registry) Creates a script instance.protected McreateScript(L script, URI uri, boolean registerSuccessful, List<LanguageUnit> inProgress, net.ssehub.easy.instantiation.core.model.buildlangModel.Imports<M> imports, net.ssehub.easy.basics.modelManagement.ImportResolver<M> impResolver) Creates a script instance from an EMF instance.protected net.ssehub.easy.instantiation.core.model.common.TypedefcreateTypedef(String name, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> type) (package private) voiderror(net.ssehub.easy.instantiation.core.model.common.VilException exception, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causeFeature) Turns a buildlang exception into a xText error.protected List<org.eclipse.emf.ecore.EObject> getContents(L script) Returns the actual contents ofscript.protected abstract net.ssehub.easy.basics.modelManagement.ModelManagement<M> Returns the management instance.protected abstract net.ssehub.easy.basics.modelManagement.IModelLoader<M> private static booleanisProtected(RuleDeclaration rule) Returns whether a rule is protected.protected voidprocessAdditionalContents(L unit, List<org.eclipse.emf.ecore.EObject> elements, M result) Extension point forprocessContents(LanguageUnit, Script).protected voidprocessContents(L script, M result) Processes the contents of a language unit and stores the results inresult.protected voidprocessGlobalVariableDeclarations(List<org.eclipse.emf.ecore.EObject> elts, M result) Processes the global script variable declarations.protected net.ssehub.easy.instantiation.core.model.buildlangModel.Imports<M> processImports(org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vil.expressions.expressionDsl.Import> imports, org.eclipse.emf.common.util.EList<Require> requires) Processes the imports and returns an summarizing instance.protected voidRe-processes global variable declarations to get rid of temporary "function pointer" expressions.private List<net.ssehub.easy.instantiation.core.model.expressions.Expression> resolveExpressions(org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vil.expressions.expressionDsl.LogicalExpression> expressions) Resolves a set of expressions.private voidresolveRuleExpressions(net.ssehub.easy.instantiation.core.model.buildlangModel.RuleDescriptor descriptor, net.ssehub.easy.instantiation.core.model.buildlangModel.Rule.Side side, org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vil.expressions.expressionDsl.LogicalExpression> expressions) Resolves rule expressions.(package private) voidwarning(net.ssehub.easy.instantiation.core.model.common.VilException exception, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causeFeature) Turns a buildlang exception into a xText warning.Methods inherited from class de.uni_hildesheim.sse.vil.expressions.translation.ModelTranslator
checkOperationAnnotations, convert, getExtensionImport, getResolver, postResolveImports, processAdvices, processCompoundContents, processCompounds, processImports, processTypedefContents, processTypedefs, processVariableDeclarations, processVariableDeclarations, resolveImports, resolveParameters, resolveParameters, warnVersionRestrictionsMethods inherited from class net.ssehub.easy.dslCore.translation.ModelTranslator
addMessage, collect, copy, error, error, getErrorCount, getExpressionTranslator, getMessage, getMessageCount, select, warningMethods inherited from class net.ssehub.easy.dslCore.translation.MessageReceiver
error
-
Field Details
-
expressionTranslator
-
resolver
private net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver resolver -
ruleTranslator
private AbstractModelTranslator<M extends net.ssehub.easy.instantiation.core.model.buildlangModel.Script,L extends LanguageUnit>.RuleTranslator ruleTranslator
-
-
Constructor Details
-
AbstractModelTranslator
public AbstractModelTranslator()Creates a model translator. -
AbstractModelTranslator
protected AbstractModelTranslator(ExpressionTranslator expressionTranslator, net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver resolver) Creates a model translator.- Parameters:
expressionTranslator- the expression translator to useresolver- the resolver to use
-
-
Method Details
-
createScript
protected M createScript(L script, URI uri, boolean registerSuccessful, List<LanguageUnit> inProgress, net.ssehub.easy.instantiation.core.model.buildlangModel.Imports<M> imports, net.ssehub.easy.basics.modelManagement.ImportResolver<M> impResolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Creates a script instance from an EMF instance.- Parameters:
script- the EMF instance to work onuri- the URI of the project to resolve (in order to find the closest project, may be null)registerSuccessful- successfully created models shall be registeredinProgress- the scripts currently being translatedimports- the global importsimpResolver- the import resolver to use (may be null to use a new default import resolver)- Returns:
- the created script
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that a problem occurred
-
processContents
protected void processContents(L script, M result) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes the contents of a language unit and stores the results inresult. Callsif the contents is processable.invalid reference
#processAdditionalContents(LanguageUnit, Script)- Parameters:
script- the script language unit to be processedresult- the result instance to be modified- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that processing fails
-
processGlobalVariableDeclarations
protected void processGlobalVariableDeclarations(List<org.eclipse.emf.ecore.EObject> elts, M result) Processes the global script variable declarations.- Parameters:
result- the result instance to be modifiedscript- the script language unit to be processed
-
reProcessGlobalVariableDeclarations
Re-processes global variable declarations to get rid of temporary "function pointer" expressions.- Parameters:
model- the model to be processed
-
getContents
Returns the actual contents ofscript.- Parameters:
script- the script to return the contents for- Returns:
- the script contents
-
processAdditionalContents
protected void processAdditionalContents(L unit, List<org.eclipse.emf.ecore.EObject> elements, M result) throws net.ssehub.easy.dslCore.translation.TranslatorException Extension point forprocessContents(LanguageUnit, Script).- Parameters:
unit- the language unit to processresult- the result instance to be modifiedscript- the script language unit to be processed- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that processing fails
-
createScript
protected abstract M createScript(String name, net.ssehub.easy.basics.modelManagement.ModelImport<M> parent, net.ssehub.easy.instantiation.core.model.buildlangModel.Script.ScriptDescriptor<M> descriptor, net.ssehub.easy.instantiation.core.model.vilTypes.TypeRegistry registry) Creates a script instance.- Parameters:
name- Name of the project.parent- the super script to inherit from (as a script import, may be null, shall be member ofimportsor also null)descriptor- the descriptor carrying parameters, advices and imports (may be null)registry- the responsible type registry
-
processImports
protected net.ssehub.easy.instantiation.core.model.buildlangModel.Imports<M> processImports(org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vil.expressions.expressionDsl.Import> imports, org.eclipse.emf.common.util.EList<Require> requires) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes the imports and returns an summarizing instance.- Parameters:
imports- the imports to be processed- Returns:
- the summarizing instance
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that processing the imports fails
-
getManagementInstance
protected abstract net.ssehub.easy.basics.modelManagement.ModelManagement<M> getManagementInstance()Returns the management instance.- Specified by:
getManagementInstancein classde.uni_hildesheim.sse.vil.expressions.translation.ModelTranslator<M extends net.ssehub.easy.instantiation.core.model.buildlangModel.Script,net.ssehub.easy.instantiation.core.model.buildlangModel.VariableDeclaration, net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver, net.ssehub.easy.instantiation.core.model.buildlangModel.ExpressionStatement, ExpressionTranslator> - Returns:
- the management instance
-
getModelLoader
-
checkConstants
protected void checkConstants(net.ssehub.easy.instantiation.core.model.buildlangModel.Script project, L cause) Performs static tests on the constants.- Parameters:
project- the project createdcause- the causing ECore element- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that a problem occurred
-
resolveExpressions
private List<net.ssehub.easy.instantiation.core.model.expressions.Expression> resolveExpressions(org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vil.expressions.expressionDsl.LogicalExpression> expressions) throws net.ssehub.easy.dslCore.translation.TranslatorException Resolves a set of expressions.- Parameters:
expressions- the expressions to be resolved- Returns:
- the resolved expression (may be less than the elements in
expressionsin case of errors) or null in case of errors - Throws:
net.ssehub.easy.dslCore.translation.TranslatorException
-
resolveRuleExpressions
private void resolveRuleExpressions(net.ssehub.easy.instantiation.core.model.buildlangModel.RuleDescriptor descriptor, net.ssehub.easy.instantiation.core.model.buildlangModel.Rule.Side side, org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vil.expressions.expressionDsl.LogicalExpression> expressions) throws net.ssehub.easy.dslCore.translation.TranslatorException Resolves rule expressions.- Parameters:
descriptor- the rule descriptor as target for the dataside- the rule sideexpressions- the expressions to be resolved- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case of resolution problems
-
createArray
protected net.ssehub.easy.instantiation.core.model.buildlangModel.VariableDeclaration[] createArray(int len) - Specified by:
createArrayin classde.uni_hildesheim.sse.vil.expressions.translation.ModelTranslator<M extends net.ssehub.easy.instantiation.core.model.buildlangModel.Script,net.ssehub.easy.instantiation.core.model.buildlangModel.VariableDeclaration, net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver, net.ssehub.easy.instantiation.core.model.buildlangModel.ExpressionStatement, ExpressionTranslator>
-
isProtected
Returns whether a rule is protected.- Parameters:
rule- the rule to be tested- Returns:
trueif it is protected,falseelse
-
error
void error(net.ssehub.easy.instantiation.core.model.common.VilException 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
-
warning
void warning(net.ssehub.easy.instantiation.core.model.common.VilException 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
-
addVisibleDeclarationsToResolver
protected void addVisibleDeclarationsToResolver(M model, net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver resolver) - Specified by:
addVisibleDeclarationsToResolverin classde.uni_hildesheim.sse.vil.expressions.translation.ModelTranslator<M extends net.ssehub.easy.instantiation.core.model.buildlangModel.Script,net.ssehub.easy.instantiation.core.model.buildlangModel.VariableDeclaration, net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver, net.ssehub.easy.instantiation.core.model.buildlangModel.ExpressionStatement, ExpressionTranslator>
-
createTypedef
protected net.ssehub.easy.instantiation.core.model.common.Typedef createTypedef(String name, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> type) throws net.ssehub.easy.instantiation.core.model.common.VilException - Specified by:
createTypedefin classde.uni_hildesheim.sse.vil.expressions.translation.ModelTranslator<M extends net.ssehub.easy.instantiation.core.model.buildlangModel.Script,net.ssehub.easy.instantiation.core.model.buildlangModel.VariableDeclaration, net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver, net.ssehub.easy.instantiation.core.model.buildlangModel.ExpressionStatement, ExpressionTranslator> - Throws:
net.ssehub.easy.instantiation.core.model.common.VilException
-
createCompound
protected net.ssehub.easy.instantiation.core.model.buildlangModel.Compound createCompound(net.ssehub.easy.instantiation.core.model.vilTypes.CompoundTypeDescriptor type) throws net.ssehub.easy.instantiation.core.model.common.VilException - Specified by:
createCompoundin classde.uni_hildesheim.sse.vil.expressions.translation.ModelTranslator<M extends net.ssehub.easy.instantiation.core.model.buildlangModel.Script,net.ssehub.easy.instantiation.core.model.buildlangModel.VariableDeclaration, net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver, net.ssehub.easy.instantiation.core.model.buildlangModel.ExpressionStatement, ExpressionTranslator> - Throws:
net.ssehub.easy.instantiation.core.model.common.VilException
-