Class ModelTranslator
java.lang.Object
net.ssehub.easy.dslCore.translation.MessageReceiver
net.ssehub.easy.dslCore.translation.ModelTranslator<ExpressionTranslator>
de.uni_hildesheim.sse.vil.expressions.translation.ModelTranslator<net.ssehub.easy.instantiation.core.model.templateModel.Template,net.ssehub.easy.instantiation.core.model.templateModel.VariableDeclaration,net.ssehub.easy.instantiation.core.model.templateModel.Resolver,net.ssehub.easy.instantiation.core.model.templateModel.ExpressionStatement,ExpressionTranslator>
de.uni_hildesheim.sse.vil.templatelang.templateLanguageTranslation.ModelTranslator
- All Implemented Interfaces:
ExpressionTranslator.IStatementTranslator,net.ssehub.easy.dslCore.translation.IMessageReceiver
public class ModelTranslator
extends de.uni_hildesheim.sse.vil.expressions.translation.ModelTranslator<net.ssehub.easy.instantiation.core.model.templateModel.Template,net.ssehub.easy.instantiation.core.model.templateModel.VariableDeclaration,net.ssehub.easy.instantiation.core.model.templateModel.Resolver,net.ssehub.easy.instantiation.core.model.templateModel.ExpressionStatement,ExpressionTranslator>
implements ExpressionTranslator.IStatementTranslator
Translates a parsed template language in ECore instances into
instances of the template language model and performs semantic
analysis.
- Author:
- Holger Eichelberger
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ExpressionTranslatorprivate net.ssehub.easy.instantiation.core.model.templateModel.Resolver -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddVisibleDeclarationsToResolver(net.ssehub.easy.instantiation.core.model.templateModel.Template model, net.ssehub.easy.instantiation.core.model.templateModel.Resolver resolver) protected net.ssehub.easy.instantiation.core.model.templateModel.VariableDeclaration[]createArray(int len) protected net.ssehub.easy.instantiation.core.model.templateModel.CompoundcreateCompound(net.ssehub.easy.instantiation.core.model.vilTypes.CompoundTypeDescriptor type) net.ssehub.easy.instantiation.core.model.templateModel.TemplatecreateModel(LanguageUnit tpl, URI uri, boolean registerSuccessful, net.ssehub.easy.basics.modelManagement.ImportResolver<net.ssehub.easy.instantiation.core.model.templateModel.Template> impResolver) Creates a build model from a given implementation unit.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.private StringReturns either the numeric or the string value ofpart.static StringReturns a string representing a qualified name.protected net.ssehub.easy.basics.modelManagement.ModelManagement<net.ssehub.easy.instantiation.core.model.templateModel.Template> Returns the management instance.private net.ssehub.easy.instantiation.core.model.templateModel.AlternativeStatementProcesses an alternative statement.private net.ssehub.easy.instantiation.core.model.templateModel.ITemplateElement[]processBlock(StmtBlock block) Processes a block of rule elements.private net.ssehub.easy.instantiation.core.model.templateModel.ContentStatementprocessContent(Content content, net.ssehub.easy.instantiation.core.model.templateModel.Resolver resolver) Processes a content statement.private net.ssehub.easy.instantiation.core.model.templateModel.DefprocessDef(VilDef def, net.ssehub.easy.instantiation.core.model.templateModel.Template template) Processes a (sub-)template definition header.private voidprocessDefBody(DefInfo info) Processes a (sub-)template body.protected voidprocessDefs(List<org.eclipse.emf.ecore.EObject> elts, net.ssehub.easy.instantiation.core.model.templateModel.Template template) Processes all template defs considering dependencies and terminates with an error if not all can be resolved.private net.ssehub.easy.instantiation.core.model.templateModel.FlushStatementProcesses a content flush statement.private net.ssehub.easy.instantiation.core.model.templateModel.FormattingConfigurationProcesses the formatting hint.protected voidprocessGlobalVariableDeclarations(List<org.eclipse.emf.ecore.EObject> elts, net.ssehub.easy.instantiation.core.model.templateModel.Template result) Processes the global script variable declarations.private net.ssehub.easy.basics.modelManagement.IndentationConfigurationProcesses an indentation hint and returns the indentation configuration.private net.ssehub.easy.instantiation.core.model.templateModel.JavaExtensionProcesses a Java extension.private net.ssehub.easy.instantiation.core.model.templateModel.JavaExtensionprocessJavaExtension(net.ssehub.easy.instantiation.core.model.templateModel.JavaExtension javaExt, Set<String> knownTypes, Set<String> knownSignatures, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causingFeature) Processes a Java extension.private voidprocessJavaExtensions(LanguageUnit tpl, net.ssehub.easy.instantiation.core.model.templateModel.TemplateDescriptor desc) Processes the Java extensions.private net.ssehub.easy.instantiation.core.model.templateModel.LoopStatementprocessLoop(Loop loop) Processes a loop expression.private net.ssehub.easy.instantiation.core.model.expressions.ExpressionprocessSeparatorExpression(de.uni_hildesheim.sse.vil.expressions.expressionDsl.PrimaryExpression ex) Processes a separator expression.net.ssehub.easy.instantiation.core.model.templateModel.ITemplateElementprocessStatement(Stmt stmt) Processes a statement.private net.ssehub.easy.instantiation.core.model.templateModel.ITemplateElementprocessStatementOrStmtBlock(Stmt stmt, StmtBlock block) Processes an alternative statement or statement block.private net.ssehub.easy.instantiation.core.model.templateModel.SwitchStatementprocessSwitch(Switch swtch) Processes a switch statement.private net.ssehub.easy.instantiation.core.model.templateModel.WhileStatementprocessWhile(While loop) Processes a while statement.protected voidreProcessGlobalVariableDeclarations(net.ssehub.easy.instantiation.core.model.templateModel.Template model) Re-processes global variable declarations to get rid of temporary "function pointer" 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.templateModel.Resolver resolver
-
-
Constructor Details
-
ModelTranslator
public ModelTranslator()Creates the model translator.
-
-
Method Details
-
createModel
public net.ssehub.easy.instantiation.core.model.templateModel.Template createModel(LanguageUnit tpl, URI uri, boolean registerSuccessful, net.ssehub.easy.basics.modelManagement.ImportResolver<net.ssehub.easy.instantiation.core.model.templateModel.Template> impResolver) Creates a build model from a given implementation unit. This is the top-level entry method.- Parameters:
tpl- the language unit to be translateduri- the URI of the project to resolve (in order to find the closest project, may be null)registerSuccessful- successfully created models shall be registeredimpResolver- the import resolver to use (may be null to use a new default import resolver)- Returns:
- the corresponding build model
-
processGlobalVariableDeclarations
protected void processGlobalVariableDeclarations(List<org.eclipse.emf.ecore.EObject> elts, net.ssehub.easy.instantiation.core.model.templateModel.Template result) Processes the global script variable declarations.- Parameters:
result- the result instance to be modifiedscript- the script language unit to be processed
-
processIndentHint
private net.ssehub.easy.basics.modelManagement.IndentationConfiguration processIndentHint(IndentationHint hint) Processes an indentation hint and returns the indentation configuration.- Parameters:
hint- the hint- Returns:
- the indentation configuration (may be null if there is no indentation hint)
-
processFormattingHint
private net.ssehub.easy.instantiation.core.model.templateModel.FormattingConfiguration processFormattingHint(FormattingHint hint) Processes the formatting hint.- Parameters:
hint- the hint to be processed- Returns:
- the related formatting configuration (may be null if there is no formatting hint)
-
getFormattingHintPartNumStringValue
Returns either the numeric or the string value ofpart.- Parameters:
part- the part- Returns:
- the value as string
-
reProcessGlobalVariableDeclarations
protected void reProcessGlobalVariableDeclarations(net.ssehub.easy.instantiation.core.model.templateModel.Template model) Re-processes global variable declarations to get rid of temporary "function pointer" expressions.- Parameters:
model- the model to be processed
-
processJavaExtensions
private void processJavaExtensions(LanguageUnit tpl, net.ssehub.easy.instantiation.core.model.templateModel.TemplateDescriptor desc) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes the Java extensions.- Parameters:
tpl- the template to be processeddesc- the template descriptor to put the information into- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that resolving/processing/adding the Java extensions fails
-
processJavaExtension
private net.ssehub.easy.instantiation.core.model.templateModel.JavaExtension processJavaExtension(Extension ext, Set<String> knownTypes, Set<String> knownSignatures) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes a Java extension.- Parameters:
ext- the extension to be processedknownTypes- known type names (may be modified as a side effect)knownSignatures- known signatures due to Java extensions (may be modified as a side effect)- Returns:
- the Java extension
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that resolving/processing/adding the Java extension fails
-
processJavaExtension
private net.ssehub.easy.instantiation.core.model.templateModel.JavaExtension processJavaExtension(net.ssehub.easy.instantiation.core.model.templateModel.JavaExtension javaExt, Set<String> knownTypes, Set<String> knownSignatures, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causingFeature) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes a Java extension.- Parameters:
knownTypes- known type names (may be modified as a side effect)knownSignatures- known signatures due to Java extensions (may be modified as a side effect)cause- the causing EObjectcausingFeature- the causing language featureext- the extension to be processed- Returns:
- the Java extension
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that resolving/processing/adding the Java extension fails
-
getJavaQualifiedNameString
Returns a string representing a qualified name. (May change in future to structured qualified names.)- Parameters:
name- the qualified name- Returns:
- the corresponding string representation
-
getManagementInstance
protected net.ssehub.easy.basics.modelManagement.ModelManagement<net.ssehub.easy.instantiation.core.model.templateModel.Template> getManagementInstance()Returns the management instance.- Specified by:
getManagementInstancein classde.uni_hildesheim.sse.vil.expressions.translation.ModelTranslator<net.ssehub.easy.instantiation.core.model.templateModel.Template,net.ssehub.easy.instantiation.core.model.templateModel.VariableDeclaration, net.ssehub.easy.instantiation.core.model.templateModel.Resolver, net.ssehub.easy.instantiation.core.model.templateModel.ExpressionStatement, ExpressionTranslator> - Returns:
- the management instance
-
processDefs
protected void processDefs(List<org.eclipse.emf.ecore.EObject> elts, net.ssehub.easy.instantiation.core.model.templateModel.Template template) Processes all template defs considering dependencies and terminates with an error if not all can be resolved.- Parameters:
template- the target template to store the defs indefs- the defs to be processed
-
processDef
private net.ssehub.easy.instantiation.core.model.templateModel.Def processDef(VilDef def, net.ssehub.easy.instantiation.core.model.templateModel.Template template) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes a (sub-)template definition header.- Parameters:
def- the sub-templatetemplate- the target template to store the def in- Returns:
- the model instance
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that processing the definition fail
-
processDefBody
private void processDefBody(DefInfo info) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes a (sub-)template body.- Parameters:
info- the def information object relating Ecore and model instance- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that processing the definition fail
-
processBlock
private net.ssehub.easy.instantiation.core.model.templateModel.ITemplateElement[] processBlock(StmtBlock block) Processes a block of rule elements.- Parameters:
block- the block to be resolved- Returns:
- the resolved elements
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails due to semantic reasons
-
processStatement
public net.ssehub.easy.instantiation.core.model.templateModel.ITemplateElement processStatement(Stmt stmt) throws net.ssehub.easy.dslCore.translation.TranslatorException Description copied from interface:ExpressionTranslator.IStatementTranslatorProcesses a statement.- Specified by:
processStatementin interfaceExpressionTranslator.IStatementTranslator- Parameters:
stmt- the statement to be resolved- Returns:
- the resolved elements
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails due to semantic reasons
-
processStatementOrStmtBlock
private net.ssehub.easy.instantiation.core.model.templateModel.ITemplateElement processStatementOrStmtBlock(Stmt stmt, StmtBlock block) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes an alternative statement or statement block.- Parameters:
stmt- the statement (may be null)block- the statement block (may be null)- Returns:
- the respective processed VTL element or null
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails due to semantic reasons
-
processAlternative
private net.ssehub.easy.instantiation.core.model.templateModel.AlternativeStatement processAlternative(Alternative alt) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes an alternative statement.- Parameters:
alt- the alternative element from the language- Returns:
- the object representation of the alternative statement
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails due to semantic reasons
-
processSeparatorExpression
private net.ssehub.easy.instantiation.core.model.expressions.Expression processSeparatorExpression(de.uni_hildesheim.sse.vil.expressions.expressionDsl.PrimaryExpression ex) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes a separator expression.- Parameters:
ex- the ECore expression tree- Returns:
- the VIL/VTL expression tree
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails
-
processWhile
private net.ssehub.easy.instantiation.core.model.templateModel.WhileStatement processWhile(While loop) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes a while statement.- Parameters:
loop- the ECore loop representation- Returns:
- the VTL while statement
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails
-
processFlush
private net.ssehub.easy.instantiation.core.model.templateModel.FlushStatement processFlush() throws net.ssehub.easy.dslCore.translation.TranslatorExceptionProcesses a content flush statement.- Returns:
- the VTL flush statement
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails
-
processLoop
private net.ssehub.easy.instantiation.core.model.templateModel.LoopStatement processLoop(Loop loop) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes a loop expression.- Parameters:
loop- the loop expression to be processed- Returns:
- the loop object model instance
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails due to semantic reasons
-
processSwitch
private net.ssehub.easy.instantiation.core.model.templateModel.SwitchStatement processSwitch(Switch swtch) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes a switch statement.- Parameters:
swtch- the switch statement from the language- Returns:
- the switch object model instance
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException- in case that the translation fails due to semantic reasons
-
processContent
private net.ssehub.easy.instantiation.core.model.templateModel.ContentStatement processContent(Content content, net.ssehub.easy.instantiation.core.model.templateModel.Resolver resolver) throws net.ssehub.easy.dslCore.translation.TranslatorException Processes a content statement.- Parameters:
content- the statement- Returns:
- the model object
- Throws:
net.ssehub.easy.dslCore.translation.TranslatorException
-
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 causing feature (as part ofcause)
-
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 causing feature (as part ofcause)
-
createArray
protected net.ssehub.easy.instantiation.core.model.templateModel.VariableDeclaration[] createArray(int len) - Specified by:
createArrayin classde.uni_hildesheim.sse.vil.expressions.translation.ModelTranslator<net.ssehub.easy.instantiation.core.model.templateModel.Template,net.ssehub.easy.instantiation.core.model.templateModel.VariableDeclaration, net.ssehub.easy.instantiation.core.model.templateModel.Resolver, net.ssehub.easy.instantiation.core.model.templateModel.ExpressionStatement, ExpressionTranslator>
-
addVisibleDeclarationsToResolver
protected void addVisibleDeclarationsToResolver(net.ssehub.easy.instantiation.core.model.templateModel.Template model, net.ssehub.easy.instantiation.core.model.templateModel.Resolver resolver) - Specified by:
addVisibleDeclarationsToResolverin classde.uni_hildesheim.sse.vil.expressions.translation.ModelTranslator<net.ssehub.easy.instantiation.core.model.templateModel.Template,net.ssehub.easy.instantiation.core.model.templateModel.VariableDeclaration, net.ssehub.easy.instantiation.core.model.templateModel.Resolver, net.ssehub.easy.instantiation.core.model.templateModel.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<net.ssehub.easy.instantiation.core.model.templateModel.Template,net.ssehub.easy.instantiation.core.model.templateModel.VariableDeclaration, net.ssehub.easy.instantiation.core.model.templateModel.Resolver, net.ssehub.easy.instantiation.core.model.templateModel.ExpressionStatement, ExpressionTranslator> - Throws:
net.ssehub.easy.instantiation.core.model.common.VilException
-
createCompound
protected net.ssehub.easy.instantiation.core.model.templateModel.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<net.ssehub.easy.instantiation.core.model.templateModel.Template,net.ssehub.easy.instantiation.core.model.templateModel.VariableDeclaration, net.ssehub.easy.instantiation.core.model.templateModel.Resolver, net.ssehub.easy.instantiation.core.model.templateModel.ExpressionStatement, ExpressionTranslator> - Throws:
net.ssehub.easy.instantiation.core.model.common.VilException
-