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

    Fields
    Modifier and Type
    Field
    Description
     
    private net.ssehub.easy.instantiation.core.model.templateModel.Resolver
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates the model translator.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    addVisibleDeclarationsToResolver(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.Compound
    createCompound(net.ssehub.easy.instantiation.core.model.vilTypes.CompoundTypeDescriptor type)
     
    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.
    protected net.ssehub.easy.instantiation.core.model.common.Typedef
    createTypedef(String name, net.ssehub.easy.instantiation.core.model.vilTypes.TypeDescriptor<?> type)
     
    (package private) 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.
    private String
    Returns either the numeric or the string value of part.
    static String
    Returns 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.AlternativeStatement
    Processes an alternative statement.
    private net.ssehub.easy.instantiation.core.model.templateModel.ITemplateElement[]
    Processes a block of rule elements.
    private net.ssehub.easy.instantiation.core.model.templateModel.ContentStatement
    processContent(Content content, net.ssehub.easy.instantiation.core.model.templateModel.Resolver resolver)
    Processes a content statement.
    private net.ssehub.easy.instantiation.core.model.templateModel.Def
    processDef(VilDef def, net.ssehub.easy.instantiation.core.model.templateModel.Template template)
    Processes a (sub-)template definition header.
    private void
    Processes a (sub-)template body.
    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.
    private net.ssehub.easy.instantiation.core.model.templateModel.FlushStatement
    Processes a content flush statement.
    private net.ssehub.easy.instantiation.core.model.templateModel.FormattingConfiguration
    Processes the formatting hint.
    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.
    private net.ssehub.easy.basics.modelManagement.IndentationConfiguration
    Processes an indentation hint and returns the indentation configuration.
    private net.ssehub.easy.instantiation.core.model.templateModel.JavaExtension
    processJavaExtension(Extension ext, Set<String> knownTypes, Set<String> knownSignatures)
    Processes a Java extension.
    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)
    Processes a Java extension.
    private void
    processJavaExtensions(LanguageUnit tpl, net.ssehub.easy.instantiation.core.model.templateModel.TemplateDescriptor desc)
    Processes the Java extensions.
    private net.ssehub.easy.instantiation.core.model.templateModel.LoopStatement
    Processes a loop expression.
    private net.ssehub.easy.instantiation.core.model.expressions.Expression
    processSeparatorExpression(de.uni_hildesheim.sse.vil.expressions.expressionDsl.PrimaryExpression ex)
    Processes a separator expression.
    net.ssehub.easy.instantiation.core.model.templateModel.ITemplateElement
    Processes a statement.
    private net.ssehub.easy.instantiation.core.model.templateModel.ITemplateElement
    Processes an alternative statement or statement block.
    private net.ssehub.easy.instantiation.core.model.templateModel.SwitchStatement
    Processes a switch statement.
    private net.ssehub.easy.instantiation.core.model.templateModel.WhileStatement
    Processes a while statement.
    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.
    (package private) 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.

    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, warnVersionRestrictions

    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • expressionTranslator

      private ExpressionTranslator 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 translated
      uri - the URI of the project to resolve (in order to find the closest project, may be null)
      registerSuccessful - successfully created models shall be registered
      impResolver - 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 modified
      script - 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

      private String getFormattingHintPartNumStringValue(FormattingHintPart part)
      Returns either the numeric or the string value of part.
      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 processed
      desc - 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 processed
      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)
      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 EObject
      causingFeature - the causing language feature
      ext - 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

      public static String getJavaQualifiedNameString(JavaQualifiedName name)
      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:
      getManagementInstance in class 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>
      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 in
      defs - 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-template
      template - 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.IStatementTranslator
      Processes a statement.
      Specified by:
      processStatement in interface ExpressionTranslator.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.TranslatorException
      Processes 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 used
      cause - the cause (as instance of the EMF grammar model)
      causeFeature - the causing feature (as part of cause)
    • 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 used
      cause - the cause (as instance of the EMF grammar model)
      causeFeature - the causing feature (as part of cause)
    • createArray

      protected net.ssehub.easy.instantiation.core.model.templateModel.VariableDeclaration[] createArray(int len)
      Specified by:
      createArray in class 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>
    • addVisibleDeclarationsToResolver

      protected void addVisibleDeclarationsToResolver(net.ssehub.easy.instantiation.core.model.templateModel.Template model, net.ssehub.easy.instantiation.core.model.templateModel.Resolver resolver)
      Specified by:
      addVisibleDeclarationsToResolver in class 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>
    • 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:
      createTypedef in class 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>
      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:
      createCompound in class 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>
      Throws:
      net.ssehub.easy.instantiation.core.model.common.VilException