Class ModelTranslator<M extends IModel,I extends VariableDeclaration,R extends Resolver<I>,S extends 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:
IMessageReceiver
- Direct Known Subclasses:
AbstractModelTranslator,ModelTranslator
public abstract class ModelTranslator<M extends IModel,I extends VariableDeclaration,R extends Resolver<I>,S extends ExpressionStatement,E extends ExpressionTranslator<I,R,S>> extends ModelTranslator<E>
A reusable model translator.- Author:
- Holger Eichelberger
-
-
Constructor Summary
Constructors Constructor Description ModelTranslator(E expressionTranslator, R resolver)Creates a new model translator.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private voidaddImportedVariablesToResolver(M model, boolean addModel, java.util.Set<M> done)Adds (transitively) imported variables to the actual resolver.protected abstract voidaddVisibleDeclarationsToResolver(M model, R resolver)Adds visible declarations ofmodeltoresolver.private voidbuildLocalTypeRegistry(Advice advice)Builds a local type registry foradvice.static Versionconvert(de.uni_hildesheim.sse.vil.expressions.expressionDsl.VersionStmt versionStatement)Converts a grammar version statement into a model version object.protected abstract I[]createArray(int len)Creates an array of .protected abstract CompoundcreateCompound(CompoundTypeDescriptor type)Creates a compound object.protected abstract TypedefcreateTypedef(java.lang.String name, TypeDescriptor<?> type)Creates a typdef object.protected ModelImport<M>getExtensionImport(java.lang.String name, 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 ModelManagement<M>getManagementInstance()Returns the management instance.protected RgetResolver()Returns the resolver instance.protected java.util.List<IMessage>postResolveImports(M model, java.net.URI uri, java.util.List<IMessage> resolutionMessages)Is called in case of resolution problems.protected Advice[]processAdvices(org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vil.expressions.expressionDsl.Advice> advices, java.net.URI modelURI)Processes the advices (of a script).protected voidprocessCompoundContents(java.util.List<org.eclipse.emf.ecore.EObject> elts, ICompoundReceiver receiver)Processes the compounds inelts.protected voidprocessCompounds(java.util.List<de.uni_hildesheim.sse.vil.expressions.expressionDsl.Compound> cmps, ICompoundReceiver receiver)Processes the given compounds.private voidprocessCompounds(java.util.List<de.uni_hildesheim.sse.vil.expressions.expressionDsl.Compound> cmps, ICompoundReceiver receiver, boolean force)Processes the given typedefs.protected Imports<M>processImports(org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vil.expressions.expressionDsl.Import> imports)Processes the imports and returns an summarizing instance.protected voidprocessTypedefContents(java.util.List<org.eclipse.emf.ecore.EObject> elts, ITypedefReceiver receiver)Processes the typedefs inelts.protected voidprocessTypedefs(java.util.List<de.uni_hildesheim.sse.vil.expressions.expressionDsl.TypeDef> defs, ITypedefReceiver receiver)Processes the given typedefs.private voidprocessTypedefs(java.util.List<de.uni_hildesheim.sse.vil.expressions.expressionDsl.TypeDef> defs, ITypedefReceiver receiver, boolean force)Processes the given typedefs.protected voidprocessVariableDeclarations(java.util.List<de.uni_hildesheim.sse.vil.expressions.expressionDsl.VariableDeclaration> decls, IVariableDeclarationReceiver<I> receiver)Processes all variable declarations considering dependencies and terminates with an error if not all can be resolved.protected voidprocessVariableDeclarations(java.util.List<de.uni_hildesheim.sse.vil.expressions.expressionDsl.VariableDeclaration> decls, IVariableDeclarationReceiver<I> receiver, boolean addToResolver)Processes all variable declarations considering dependencies and terminates with an error if not all can be resolved.private voidprocessVariableDeclarations(java.util.List<de.uni_hildesheim.sse.vil.expressions.expressionDsl.VariableDeclaration> decls, 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(de.uni_hildesheim.sse.vil.expressions.expressionDsl.LanguageUnit input, org.eclipse.emf.ecore.EStructuralFeature inputFeature, M model, java.net.URI uri, java.util.List<? extends de.uni_hildesheim.sse.vil.expressions.expressionDsl.LanguageUnit> inProgress, ImportResolver<M> impResolver)Resolves the imports.protected I[]resolveParameters(de.uni_hildesheim.sse.vil.expressions.expressionDsl.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<de.uni_hildesheim.sse.vil.expressions.expressionDsl.Parameter> parameters, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature paramListFeature, R resolver)Resolves the parameters inparameters.protected voidwarnVersionRestrictions(de.uni_hildesheim.sse.vil.expressions.expressionDsl.VersionSpec spec)Issues 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, warning
-
Methods inherited from class net.ssehub.easy.dslCore.translation.MessageReceiver
error
-
-
-
-
Method Detail
-
getResolver
protected R getResolver()
Returns the resolver instance.- Returns:
- the resolver
-
processImports
protected Imports<M> processImports(org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vil.expressions.expressionDsl.Import> imports) throws TranslatorException
Processes the imports and returns an summarizing instance.- Parameters:
imports- the imports to be processed- Returns:
- the summarizing instance
- Throws:
TranslatorException- in case that processing the imports fails
-
getExtensionImport
protected ModelImport<M> getExtensionImport(java.lang.String name, Imports<M> imports, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causingFeature) throws 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:
TranslatorException- in case that the import cannot be found
-
processTypedefContents
protected void processTypedefContents(java.util.List<org.eclipse.emf.ecore.EObject> elts, ITypedefReceiver receiver)Processes the typedefs inelts.- Parameters:
elts- the elementsreceiver- the typedef receiver
-
processCompoundContents
protected void processCompoundContents(java.util.List<org.eclipse.emf.ecore.EObject> elts, ICompoundReceiver receiver)Processes the compounds inelts.- Parameters:
elts- the elementsreceiver- the compound receiver
-
processTypedefs
protected void processTypedefs(java.util.List<de.uni_hildesheim.sse.vil.expressions.expressionDsl.TypeDef> defs, ITypedefReceiver receiver)Processes the given typedefs.- Parameters:
defs- the typedefsreceiver- the typedef receiver
-
processCompounds
protected void processCompounds(java.util.List<de.uni_hildesheim.sse.vil.expressions.expressionDsl.Compound> cmps, ICompoundReceiver receiver)Processes the given compounds.- Parameters:
defs- the compoundsreceiver- the compozbd receiver
-
processTypedefs
private void processTypedefs(java.util.List<de.uni_hildesheim.sse.vil.expressions.expressionDsl.TypeDef> defs, 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(java.util.List<de.uni_hildesheim.sse.vil.expressions.expressionDsl.Compound> cmps, ICompoundReceiver receiver, boolean force)Processes the given typedefs.- Parameters:
defs- the typedefsreceiver- the typedef receiverforce- force processing typedefs not resolved so far
-
createTypedef
protected abstract Typedef createTypedef(java.lang.String name, TypeDescriptor<?> type) throws VilException
Creates a typdef object.- Parameters:
name- the name of the typdef/aliastype- the the type- Returns:
- the typedef
- Throws:
VilException
-
createCompound
protected abstract Compound createCompound(CompoundTypeDescriptor type) throws VilException
Creates a compound object.- Parameters:
type- the the compound type- Returns:
- the typedef
- Throws:
VilException
-
processVariableDeclarations
protected void processVariableDeclarations(java.util.List<de.uni_hildesheim.sse.vil.expressions.expressionDsl.VariableDeclaration> decls, 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(java.util.List<de.uni_hildesheim.sse.vil.expressions.expressionDsl.VariableDeclaration> decls, 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(java.util.List<de.uni_hildesheim.sse.vil.expressions.expressionDsl.VariableDeclaration> decls, 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 Advice[] processAdvices(org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vil.expressions.expressionDsl.Advice> advices, java.net.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(Advice advice)
Builds a local type registry foradvice.- Parameters:
advice- the advice to build the local type registry for
-
warnVersionRestrictions
protected void warnVersionRestrictions(de.uni_hildesheim.sse.vil.expressions.expressionDsl.VersionSpec spec)
Issues implementation warnings about version restrictions.- Parameters:
spec- the version specification (may be null)
-
resolveParameters
protected I[] resolveParameters(de.uni_hildesheim.sse.vil.expressions.expressionDsl.ParameterList pList, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature paramListFeature, R resolver) throws 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:
TranslatorException- in case that a problem occurred
-
resolveParameters
protected I[] resolveParameters(org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vil.expressions.expressionDsl.Parameter> parameters, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature paramListFeature, R resolver) throws 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:
TranslatorException- in case that a problem occurred
-
createArray
protected abstract I[] createArray(int len)
Creates an array of .- Parameters:
len- the length of the array- Returns:
- the array
-
convert
public static Version convert(de.uni_hildesheim.sse.vil.expressions.expressionDsl.VersionStmt versionStatement)
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 ModelManagement<M> getManagementInstance()
Returns the management instance.- Returns:
- the management instance
-
resolveImports
protected void resolveImports(de.uni_hildesheim.sse.vil.expressions.expressionDsl.LanguageUnit input, org.eclipse.emf.ecore.EStructuralFeature inputFeature, M model, java.net.URI uri, java.util.List<? extends de.uni_hildesheim.sse.vil.expressions.expressionDsl.LanguageUnit> inProgress, 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
private void addImportedVariablesToResolver(M model, boolean addModel, java.util.Set<M> done)
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(IModel, Resolver)
-
addVisibleDeclarationsToResolver
protected abstract void addVisibleDeclarationsToResolver(M model, R resolver)
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 java.util.List<IMessage> postResolveImports(M model, java.net.URI uri, java.util.List<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
-
-