Class AbstractModelTranslator<M extends Script,​L extends de.uni_hildesheim.sse.vilBuildLanguage.LanguageUnit>

    • Constructor Detail

      • AbstractModelTranslator

        public AbstractModelTranslator()
        Creates a model translator.
      • AbstractModelTranslator

        protected AbstractModelTranslator​(ExpressionTranslator expressionTranslator,
                                          Resolver resolver)
        Creates a model translator.
        Parameters:
        expressionTranslator - the expression translator to use
        resolver - the resolver to use
    • Method Detail

      • createScript

        protected M createScript​(L script,
                                 java.net.URI uri,
                                 boolean registerSuccessful,
                                 java.util.List<de.uni_hildesheim.sse.vilBuildLanguage.LanguageUnit> inProgress,
                                 Imports<M> imports,
                                 ImportResolver<M> impResolver)
                          throws TranslatorException
        Creates a script instance from an EMF instance.
        Parameters:
        script - the EMF instance to work on
        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
        inProgress - the scripts currently being translated
        imports - the global imports
        impResolver - the import resolver to use (may be null to use a new default import resolver)
        Returns:
        the created script
        Throws:
        TranslatorException - in case that a problem occurred
      • processContents

        protected void processContents​(L script,
                                       M result)
                                throws TranslatorException
        Processes the contents of a language unit and stores the results in result. Calls #processAdditionalContents(LanguageUnit, Script) if the contents is processable.
        Parameters:
        script - the script language unit to be processed
        result - the result instance to be modified
        Throws:
        TranslatorException - in case that processing fails
      • processGlobalVariableDeclarations

        protected void processGlobalVariableDeclarations​(java.util.List<org.eclipse.emf.ecore.EObject> elts,
                                                         M result)
        Processes the global script variable declarations.
        Parameters:
        script - the script language unit to be processed
        result - the result instance to be modified
      • reProcessGlobalVariableDeclarations

        protected void reProcessGlobalVariableDeclarations​(M model)
        Re-processes global variable declarations to get rid of temporary "function pointer" expressions.
        Parameters:
        model - the model to be processed
      • getContents

        protected java.util.List<org.eclipse.emf.ecore.EObject> getContents​(L script)
        Returns the actual contents of script.
        Parameters:
        script - the script to return the contents for
        Returns:
        the script contents
      • processAdditionalContents

        protected void processAdditionalContents​(L unit,
                                                 java.util.List<org.eclipse.emf.ecore.EObject> elements,
                                                 M result)
                                          throws TranslatorException
        Parameters:
        unit - the language unit to process
        script - the script language unit to be processed
        result - the result instance to be modified
        Throws:
        TranslatorException - in case that processing fails
      • createScript

        protected abstract M createScript​(java.lang.String name,
                                          ModelImport<M> parent,
                                          Script.ScriptDescriptor<M> descriptor,
                                          TypeRegistry registry)
        Creates a script instance.
        Parameters:
        name - Name of the project.
        parent - the super script to inherit from (as a script import, may be null, shall be member of imports or also null)
        descriptor - the descriptor carrying parameters, advices and imports (may be null)
        registry - the responsible type registry
      • processImports

        protected Imports<M> processImports​(org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vil.expressions.expressionDsl.Import> imports,
                                            org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vilBuildLanguage.Require> requires)
                                     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
      • getModelLoader

        protected abstract IModelLoader<M> getModelLoader()
      • checkConstants

        protected void checkConstants​(Script project,
                                      L cause)
        Performs static tests on the constants.
        Parameters:
        project - the project created
        cause - the causing ECore element
        Throws:
        TranslatorException - in case that a problem occurred
      • resolveExpressions

        private java.util.List<Expression> resolveExpressions​(org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vil.expressions.expressionDsl.LogicalExpression> expressions)
                                                       throws TranslatorException
        Resolves a set of expressions.
        Parameters:
        expressions - the expressions to be resolved
        Returns:
        the resolved expression (may be less than the elements in expressions in case of errors) or null in case of errors
        Throws:
        TranslatorException
      • resolveRuleExpressions

        private void resolveRuleExpressions​(RuleDescriptor descriptor,
                                            Rule.Side side,
                                            org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vil.expressions.expressionDsl.LogicalExpression> expressions)
                                     throws TranslatorException
        Resolves rule expressions.
        Parameters:
        descriptor - the rule descriptor as target for the data
        side - the rule side
        expressions - the expressions to be resolved
        Throws:
        TranslatorException - in case of resolution problems
      • isProtected

        private static boolean isProtected​(de.uni_hildesheim.sse.vilBuildLanguage.RuleDeclaration rule)
        Returns whether a rule is protected.
        Parameters:
        rule - the rule to be tested
        Returns:
        true if it is protected, false else
      • 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 cause of the feature
      • 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 cause of the feature