Class ModelTranslator<M extends net.ssehub.easy.basics.modelManagement.IModel,I extends net.ssehub.easy.instantiation.core.model.common.VariableDeclaration,R extends net.ssehub.easy.instantiation.core.model.expressions.Resolver<I>,S extends net.ssehub.easy.instantiation.core.model.common.ExpressionStatement,E extends ExpressionTranslator<I,R,S>>
java.lang.Object
net.ssehub.easy.dslCore.translation.MessageReceiver
net.ssehub.easy.dslCore.translation.ModelTranslator<E>
de.uni_hildesheim.sse.vil.expressions.translation.ModelTranslator<M,I,R,S,E>
- Type Parameters:
I- the variable declaration typeR- the resolver typeE- the expression translator type
- All Implemented Interfaces:
net.ssehub.easy.dslCore.translation.IMessageReceiver
public abstract class ModelTranslator<M extends net.ssehub.easy.basics.modelManagement.IModel,I extends net.ssehub.easy.instantiation.core.model.common.VariableDeclaration,R extends net.ssehub.easy.instantiation.core.model.expressions.Resolver<I>,S extends net.ssehub.easy.instantiation.core.model.common.ExpressionStatement,E extends ExpressionTranslator<I,R,S>>
extends net.ssehub.easy.dslCore.translation.ModelTranslator<E>
A reusable model translator.
- Author:
- Holger Eichelberger
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionModelTranslator(E expressionTranslator, R resolver) Creates a new model translator. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddImportedVariablesToResolver(M model, boolean addModel, Set<M> done) Adds (transitively) imported variables to the actual resolver.protected abstract voidaddVisibleDeclarationsToResolver(M model, R resolver) Adds visible declarations ofmodeltoresolver.private voidbuildLocalTypeRegistry(net.ssehub.easy.instantiation.core.model.common.Advice advice) Builds a local type registry foradvice.protected <O extends net.ssehub.easy.instantiation.core.model.common.IResolvableOperation<I>>
voidcheckOperationAnnotations(O op, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causingFeature) Checks operation annotation consistency and emits warnings/errors.static net.ssehub.easy.basics.modelManagement.Versionconvert(VersionStmt versionStatement) Converts a grammar version statement into a model version object.protected abstract I[]createArray(int len) Creates an array of .protected abstract net.ssehub.easy.instantiation.core.model.common.CompoundcreateCompound(net.ssehub.easy.instantiation.core.model.vilTypes.CompoundTypeDescriptor type) Creates a compound object.protected abstract net.ssehub.easy.instantiation.core.model.common.TypedefcreateTypedef(String name, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> type) Creates a typdef object.protected net.ssehub.easy.basics.modelManagement.ModelImport<M> getExtensionImport(String name, net.ssehub.easy.instantiation.core.model.common.Imports<M> imports, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causingFeature) Returns an extension import (super script, super template).protected abstract net.ssehub.easy.basics.modelManagement.ModelManagement<M> Returns the management instance.protected RReturns the resolver instance.protected List<net.ssehub.easy.basics.messages.IMessage> postResolveImports(M model, URI uri, List<net.ssehub.easy.basics.messages.IMessage> resolutionMessages) Is called in case of resolution problems.protected net.ssehub.easy.instantiation.core.model.common.Advice[]processAdvices(org.eclipse.emf.common.util.EList<Advice> advices, URI modelURI) Processes the advices (of a script).protected voidprocessCompoundContents(List<org.eclipse.emf.ecore.EObject> elts, net.ssehub.easy.instantiation.core.model.common.ICompoundReceiver receiver) Processes the compounds inelts.protected voidprocessCompounds(List<Compound> cmps, net.ssehub.easy.instantiation.core.model.common.ICompoundReceiver receiver) Processes the given compounds.private voidprocessCompounds(List<Compound> cmps, net.ssehub.easy.instantiation.core.model.common.ICompoundReceiver receiver, boolean force) Processes the given typedefs.protected net.ssehub.easy.instantiation.core.model.common.Imports<M> processImports(org.eclipse.emf.common.util.EList<Import> imports) Processes the imports and returns an summarizing instance.protected voidprocessTypedefContents(List<org.eclipse.emf.ecore.EObject> elts, net.ssehub.easy.instantiation.core.model.common.ITypedefReceiver receiver) Processes the typedefs inelts.protected voidprocessTypedefs(List<TypeDef> defs, net.ssehub.easy.instantiation.core.model.common.ITypedefReceiver receiver) Processes the given typedefs.private voidprocessTypedefs(List<TypeDef> defs, net.ssehub.easy.instantiation.core.model.common.ITypedefReceiver receiver, boolean force) Processes the given typedefs.protected voidprocessVariableDeclarations(List<VariableDeclaration> decls, net.ssehub.easy.instantiation.core.model.common.IVariableDeclarationReceiver<I> receiver) Processes all variable declarations considering dependencies and terminates with an error if not all can be resolved.protected voidprocessVariableDeclarations(List<VariableDeclaration> decls, net.ssehub.easy.instantiation.core.model.common.IVariableDeclarationReceiver<I> receiver, boolean addToResolver) Processes all variable declarations considering dependencies and terminates with an error if not all can be resolved.private voidprocessVariableDeclarations(List<VariableDeclaration> decls, net.ssehub.easy.instantiation.core.model.common.IVariableDeclarationReceiver<I> receiver, boolean force, boolean addToResolver) Processes a set of variable declarations and adds successfully processed ones to the current resolver level.protected voidresolveImports(LanguageUnit input, org.eclipse.emf.ecore.EStructuralFeature inputFeature, M model, URI uri, List<? extends LanguageUnit> inProgress, net.ssehub.easy.basics.modelManagement.ImportResolver<M> impResolver) Resolves the imports.protected I[]resolveParameters(ParameterList pList, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature paramListFeature, R resolver) Resolves the parameters inpList.protected I[]resolveParameters(org.eclipse.emf.common.util.EList<Parameter> parameters, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature paramListFeature, R resolver) Resolves the parameters inparameters.protected voidIssues implementation warnings about version restrictions.Methods 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
-
resolver
-
-
Constructor Details
-
ModelTranslator
Creates a new model translator.- Parameters:
expressionTranslator- the expression translator instanceresolver- the resolver instance
-
-
Method Details
-
getResolver
Returns the resolver instance.- Returns:
- the resolver
-
processImports
protected net.ssehub.easy.instantiation.core.model.common.Imports<M> processImports(org.eclipse.emf.common.util.EList<Import> imports) 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
-
getExtensionImport
protected net.ssehub.easy.basics.modelManagement.ModelImport<M> getExtensionImport(String name, net.ssehub.easy.instantiation.core.model.common.Imports<M> imports, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causingFeature) throws net.ssehub.easy.dslCore.translation.TranslatorException Returns an extension import (super script, super template).- Parameters:
name- the name of the modelimports- the known importscause- the causing ECore element (in case of throwing an exception)causingFeature- the causing feature (in case of throwing an exception)- Returns:
- the found import
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the import cannot be found
-
processTypedefContents
protected void processTypedefContents(List<org.eclipse.emf.ecore.EObject> elts, net.ssehub.easy.instantiation.core.model.common.ITypedefReceiver receiver) Processes the typedefs inelts.- Parameters:
elts- the elementsreceiver- the typedef receiver
-
processCompoundContents
protected void processCompoundContents(List<org.eclipse.emf.ecore.EObject> elts, net.ssehub.easy.instantiation.core.model.common.ICompoundReceiver receiver) Processes the compounds inelts.- Parameters:
elts- the elementsreceiver- the compound receiver
-
processTypedefs
protected void processTypedefs(List<TypeDef> defs, net.ssehub.easy.instantiation.core.model.common.ITypedefReceiver receiver) Processes the given typedefs.- Parameters:
defs- the typedefsreceiver- the typedef receiver
-
processCompounds
protected void processCompounds(List<Compound> cmps, net.ssehub.easy.instantiation.core.model.common.ICompoundReceiver receiver) Processes the given compounds.- Parameters:
receiver- the compozbd receiverdefs- the compounds
-
processTypedefs
private void processTypedefs(List<TypeDef> defs, net.ssehub.easy.instantiation.core.model.common.ITypedefReceiver receiver, boolean force) Processes the given typedefs.- Parameters:
defs- the typedefsreceiver- the typedef receiverforce- force processing typedefs not resolved so far
-
processCompounds
private void processCompounds(List<Compound> cmps, net.ssehub.easy.instantiation.core.model.common.ICompoundReceiver receiver, boolean force) Processes the given typedefs.- Parameters:
receiver- the typedef receiverforce- force processing typedefs not resolved so fardefs- the typedefs
-
createTypedef
protected abstract 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 Creates a typdef object.- Parameters:
name- the name of the typdef/aliastype- the the type- Returns:
- the typedef
- Throws:
net.ssehub.easy.instantiation.core.model.common.VilException
-
createCompound
protected abstract net.ssehub.easy.instantiation.core.model.common.Compound createCompound(net.ssehub.easy.instantiation.core.model.vilTypes.CompoundTypeDescriptor type) throws net.ssehub.easy.instantiation.core.model.common.VilException Creates a compound object.- Parameters:
type- the the compound type- Returns:
- the typedef
- Throws:
net.ssehub.easy.instantiation.core.model.common.VilException
-
processVariableDeclarations
protected void processVariableDeclarations(List<VariableDeclaration> decls, net.ssehub.easy.instantiation.core.model.common.IVariableDeclarationReceiver<I> receiver) Processes all variable declarations considering dependencies and terminates with an error if not all can be resolved.- Parameters:
decls- the declarations to be processedreceiver- a receiver for the created instances
-
processVariableDeclarations
protected void processVariableDeclarations(List<VariableDeclaration> decls, net.ssehub.easy.instantiation.core.model.common.IVariableDeclarationReceiver<I> receiver, boolean addToResolver) Processes all variable declarations considering dependencies and terminates with an error if not all can be resolved.- Parameters:
decls- the declarations to be processedreceiver- a receiver for the created instancesaddToResolver- add the newly created variables to the resolver instance
-
processVariableDeclarations
private void processVariableDeclarations(List<VariableDeclaration> decls, net.ssehub.easy.instantiation.core.model.common.IVariableDeclarationReceiver<I> receiver, boolean force, boolean addToResolver) Processes a set of variable declarations and adds successfully processed ones to the current resolver level.- Parameters:
decls- the declarations to be processed (successfully processed declarations will be removed, may be modified as a side effect)receiver- a receiver for the created instancesforce- iftruea failing variable creation will be recorded as an error,falsefailing creations will be ignoredaddToResolver- add the newly created variable to the resolver instance
-
processAdvices
protected net.ssehub.easy.instantiation.core.model.common.Advice[] processAdvices(org.eclipse.emf.common.util.EList<Advice> advices, URI modelURI) Processes the advices (of a script).- Parameters:
advices- the advices to be processedmodelURI- the URI to the model being processed- Returns:
- the processed advices
-
buildLocalTypeRegistry
private void buildLocalTypeRegistry(net.ssehub.easy.instantiation.core.model.common.Advice advice) Builds a local type registry foradvice.- Parameters:
advice- the advice to build the local type registry for
-
warnVersionRestrictions
Issues implementation warnings about version restrictions.- Parameters:
spec- the version specification (may be null)
-
resolveParameters
protected I[] resolveParameters(ParameterList pList, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature paramListFeature, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Resolves the parameters inpList.- Parameters:
pList- the parameter list to be resolvedcause- the causing object containing the parametersparamListFeature- the param list feature oncauseresolver- the resolver instance- Returns:
- the resolved parameters (may actually be less then in
pListin case of name or type failures - Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that a problem occurred
-
resolveParameters
protected I[] resolveParameters(org.eclipse.emf.common.util.EList<Parameter> parameters, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature paramListFeature, R resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Resolves the parameters inparameters.- Parameters:
parameters- the parameters to be resolvedcause- the causing object containing the parametersparamListFeature- the param list feature oncauseresolver- the resolver instance- Returns:
- the resolved parameters (may actually be less then in
pListin case of name or type failures - Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that a problem occurred
-
createArray
Creates an array of .- Parameters:
len- the length of the array- Returns:
- the array
-
convert
Converts a grammar version statement into a model version object.- Parameters:
versionStatement- the version statement to be converts- Returns:
- the resulting model version object
-
getManagementInstance
protected abstract net.ssehub.easy.basics.modelManagement.ModelManagement<M> getManagementInstance()Returns the management instance.- Returns:
- the management instance
-
resolveImports
protected void resolveImports(LanguageUnit input, org.eclipse.emf.ecore.EStructuralFeature inputFeature, M model, URI uri, List<? extends LanguageUnit> inProgress, net.ssehub.easy.basics.modelManagement.ImportResolver<M> impResolver) Resolves the imports.- Parameters:
input- the input language elementinputFeature- the EMF feature this resolution happens onmodel- the model being createduri- the physical URI of the projectinProgress- the other projects being resolved at once (in order to avoid loops)
-
addImportedVariablesToResolver
Adds (transitively) imported variables to the actual resolver.- Parameters:
model- the model to consideraddModel- whether the variables ofmodelshall be added (true) or whether only its imports shall be traverseddone- collects models that are already processed- See Also:
-
addVisibleDeclarationsToResolver
Adds visible declarations ofmodeltoresolver. This method shall not consider imports as it is called byaddImportedVariablesToResolver(IModel, boolean, Set).- Parameters:
model- the model to considerresolver- the resolver to add variables to
-
postResolveImports
protected List<net.ssehub.easy.basics.messages.IMessage> postResolveImports(M model, URI uri, List<net.ssehub.easy.basics.messages.IMessage> resolutionMessages) Is called in case of resolution problems.- Parameters:
model- the model to be resolveduri- the physical URI of the projectresolutionMessages- the messages collected so far- Returns:
- the new resolution messages
-
checkOperationAnnotations
protected <O extends net.ssehub.easy.instantiation.core.model.common.IResolvableOperation<I>> void checkOperationAnnotations(O op, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causingFeature) Checks operation annotation consistency and emits warnings/errors.- Type Parameters:
O- the operation type- Parameters:
op- the operation to checkcause- the causing ECore element (in case of throwing an exception)causingFeature- the causing feature (in case of throwing an exception)
-