Class ModelTranslator

    • Constructor Detail

      • ModelTranslator

        public ModelTranslator()
        Creates the model translator.
    • Method Detail

      • createModel

        public Template createModel​(de.uni_hildesheim.sse.vil.templatelang.templateLang.LanguageUnit tpl,
                                    java.net.URI uri,
                                    boolean registerSuccessful,
                                    ImportResolver<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​(java.util.List<org.eclipse.emf.ecore.EObject> elts,
                                                         Template result)
        Processes the global script variable declarations.
        Parameters:
        script - the script language unit to be processed
        result - the result instance to be modified
      • processIndentHint

        private IndentationConfiguration processIndentHint​(de.uni_hildesheim.sse.vil.templatelang.templateLang.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 FormattingConfiguration processFormattingHint​(de.uni_hildesheim.sse.vil.templatelang.templateLang.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)
      • reProcessGlobalVariableDeclarations

        protected void reProcessGlobalVariableDeclarations​(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​(de.uni_hildesheim.sse.vil.templatelang.templateLang.LanguageUnit tpl,
                                           TemplateDescriptor desc)
                                    throws TranslatorException
        Processes the Java extensions.
        Parameters:
        tpl - the template to be processed
        desc - the template descriptor to put the information into
        Throws:
        TranslatorException - in case that resolving/processing/adding the Java extensions fails
      • processJavaExtension

        private JavaExtension processJavaExtension​(de.uni_hildesheim.sse.vil.templatelang.templateLang.Extension ext,
                                                   java.util.Set<java.lang.String> knownTypes,
                                                   java.util.Set<java.lang.String> knownSignatures)
                                            throws 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:
        TranslatorException - in case that resolving/processing/adding the Java extension fails
      • processJavaExtension

        private JavaExtension processJavaExtension​(JavaExtension javaExt,
                                                   java.util.Set<java.lang.String> knownTypes,
                                                   java.util.Set<java.lang.String> knownSignatures,
                                                   org.eclipse.emf.ecore.EObject cause,
                                                   org.eclipse.emf.ecore.EStructuralFeature causingFeature)
                                            throws 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)
        cause - the causing EObject
        causingFeature - the causing language feature
        Returns:
        the Java extension
        Throws:
        TranslatorException - in case that resolving/processing/adding the Java extension fails
      • getJavaQualifiedNameString

        public static java.lang.String getJavaQualifiedNameString​(de.uni_hildesheim.sse.vil.templatelang.templateLang.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
      • processDefs

        protected void processDefs​(java.util.List<org.eclipse.emf.ecore.EObject> elts,
                                   Template template)
        Processes all template defs considering dependencies and terminates with an error if not all can be resolved.
        Parameters:
        defs - the defs to be processed
        template - the target template to store the defs in
      • processDef

        private Def processDef​(de.uni_hildesheim.sse.vil.templatelang.templateLang.VilDef def,
                               Template template)
                        throws 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:
        TranslatorException - in case that processing the definition fail
      • processDefBody

        private void processDefBody​(DefInfo info)
                             throws TranslatorException
        Processes a (sub-)template body.
        Parameters:
        info - the def information object relating Ecore and model instance
        Throws:
        TranslatorException - in case that processing the definition fail
      • processBlock

        private ITemplateElement[] processBlock​(de.uni_hildesheim.sse.vil.templatelang.templateLang.StmtBlock block)
        Processes a block of rule elements.
        Parameters:
        block - the block to be resolved
        Returns:
        the resolved elements
        Throws:
        TranslatorException - in case that the translation fails due to semantic reasons
      • processStatement

        private ITemplateElement processStatement​(de.uni_hildesheim.sse.vil.templatelang.templateLang.Stmt stmt)
                                           throws TranslatorException
        Processes a statement.
        Parameters:
        stmt - the statement to be resolved
        Returns:
        the resolved elements
        Throws:
        TranslatorException - in case that the translation fails due to semantic reasons
      • processStatementOrStmtBlock

        private ITemplateElement processStatementOrStmtBlock​(de.uni_hildesheim.sse.vil.templatelang.templateLang.Stmt stmt,
                                                             de.uni_hildesheim.sse.vil.templatelang.templateLang.StmtBlock block)
                                                      throws 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:
        TranslatorException - in case that the translation fails due to semantic reasons
      • processAlternative

        private AlternativeStatement processAlternative​(de.uni_hildesheim.sse.vil.templatelang.templateLang.Alternative alt)
                                                 throws TranslatorException
        Processes an alternative statement.
        Parameters:
        alt - the alternative element from the language
        Returns:
        the object representation of the alternative statement
        Throws:
        TranslatorException - in case that the translation fails due to semantic reasons
      • processSeparatorExpression

        private Expression processSeparatorExpression​(de.uni_hildesheim.sse.vil.expressions.expressionDsl.PrimaryExpression ex)
                                               throws TranslatorException
        Processes a separator expression.
        Parameters:
        ex - the ECore expression tree
        Returns:
        the VIL/VTL expression tree
        Throws:
        TranslatorException - in case that the translation fails
      • processWhile

        private WhileStatement processWhile​(de.uni_hildesheim.sse.vil.templatelang.templateLang.While loop)
                                     throws TranslatorException
        Processes a while statement.
        Parameters:
        loop - the ECore loop representation
        Returns:
        the VTL while statement
        Throws:
        TranslatorException - in case that the translation fails
      • processLoop

        private LoopStatement processLoop​(de.uni_hildesheim.sse.vil.templatelang.templateLang.Loop loop)
                                   throws TranslatorException
        Processes a loop expression.
        Parameters:
        loop - the loop expression to be processed
        Returns:
        the loop object model instance
        Throws:
        TranslatorException - in case that the translation fails due to semantic reasons
      • processSwitch

        private SwitchStatement processSwitch​(de.uni_hildesheim.sse.vil.templatelang.templateLang.Switch swtch)
                                       throws TranslatorException
        Processes a switch statement.
        Parameters:
        swtch - the switch statement from the language
        Returns:
        the switch object model instance
        Throws:
        TranslatorException - in case that the translation fails due to semantic reasons
      • error

        void error​(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​(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)