Class ModelTranslator

  • All Implemented Interfaces:
    net.ssehub.easy.dslCore.translation.IMessageReceiver

    public class ModelTranslator
    extends net.ssehub.easy.dslCore.translation.ModelTranslator<ExpressionTranslator>
    Implements a ECore-to-IVML translator. Please note that errors which occur during translation are not signalled as individual exceptions but collected and accessible through ModelTranslator.getMessage(int).
    Author:
    Holger Eichelberger
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private class  ModelTranslator.EvalBlockResult
      Temporary result of evalu block processing.
      static class  ModelTranslator.Result
      Implements a translation result enabling deferred model loading.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Map<de.uni_hildesheim.sse.ivml.AttrAssignment,​net.ssehub.easy.varModel.model.AttributeAssignment> assignmentMapping  
      private java.util.Map<de.uni_hildesheim.sse.ivml.TypedefCompound,​net.ssehub.easy.varModel.model.datatypes.Compound> compoundMapping  
      private java.util.Set<org.eclipse.emf.ecore.EObject> definitionsProcessed  
      private DerivedTypeMetaCompoundAccessVisitor derivedTypeVisitor  
      private ExpressionTranslator expressionTranslator
      Contains an expression translator instance.
      private net.ssehub.easy.basics.modelManagement.IModelProcessingListener<net.ssehub.easy.varModel.model.Project> onLoadMsgCleanupListener  
      private java.util.Map<de.uni_hildesheim.sse.ivml.TypedefMapping,​net.ssehub.easy.varModel.model.datatypes.DerivedDatatype> typedefMapping  
      private java.util.Map<de.uni_hildesheim.sse.ivml.VariableDeclarationPart,​net.ssehub.easy.varModel.model.DecisionVariableDeclaration> varMapping  
    • Constructor Summary

      Constructors 
      Constructor Description
      ModelTranslator()
      Creates a model translator instance.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void alreadyDefinedError​(java.lang.String name, org.eclipse.emf.ecore.EObject object, org.eclipse.emf.ecore.EStructuralFeature feature)
      Emits an already defined error.
      private void assignComments​(net.ssehub.easy.varModel.model.StructuredComment target, java.util.List<?> elements, java.util.List<net.ssehub.easy.varModel.model.Comment> comments, net.ssehub.easy.varModel.model.IModelElement parent)
      Assigns the comments in comments to the corresponding model elements in elements.
      private void assignProjectComment​(net.ssehub.easy.varModel.model.Project project, java.lang.Object element, net.ssehub.easy.varModel.model.Comment comment)
      Assigns a comment to an element directly assigned to a project and ensures the existence the structured comment for the project if required.
      private boolean attributeAssignmentsResolvable​(java.util.List<de.uni_hildesheim.sse.ivml.AttrAssignment> attrAssignments, TypeContext context, net.ssehub.easy.varModel.model.IDecisionVariableContainer parent, boolean force)
      Returns whether the assignments in attrAssignments can be resolved in the given context and the given parent container.
      private void checkCompound​(de.uni_hildesheim.sse.ivml.Project eProject, net.ssehub.easy.varModel.model.datatypes.Compound cmp, java.util.Map<net.ssehub.easy.varModel.model.datatypes.Compound,​de.uni_hildesheim.sse.ivml.TypedefCompound> cmpMapping, java.util.Map<java.lang.String,​net.ssehub.easy.varModel.model.DecisionVariableDeclaration> done)
      Checks the given compound.
      private void checkCompounds​(de.uni_hildesheim.sse.ivml.Project eProject, net.ssehub.easy.varModel.model.Project project)
      Checks the compounds in this project.
      private void checkDefaultParamSequence​(de.uni_hildesheim.sse.ivml.OpDefStatement op, net.ssehub.easy.varModel.model.DecisionVariableDeclaration[] param)
      Checks the sequence of default and non-default parameters.
      (package private) void completeLoading​(ResultEntry entry)
      Complete loading of a given model.
      ModelTranslator.Result createEmptyResult​(java.net.URI uri)
      Creates an empty result for failure cases.
      ModelTranslator.Result createModel​(de.uni_hildesheim.sse.ivml.VariabilityUnit unit, java.net.URI uri, boolean registerSuccessful, net.ssehub.easy.basics.modelManagement.ImportResolver<net.ssehub.easy.varModel.model.Project> impResolver)
      Creates a variability model from a given variability unit.
      private ResultEntry createProject​(de.uni_hildesheim.sse.ivml.Project project, java.net.URI uri, boolean registerSuccessful, java.util.List<de.uni_hildesheim.sse.ivml.Project> inProgress, net.ssehub.easy.basics.modelManagement.ImportResolver<net.ssehub.easy.varModel.model.Project> impResolver)
      Creates a variability model from a given ECore representation of a project.
      private net.ssehub.easy.varModel.model.StructuredComment createStructuredComment​(org.eclipse.emf.ecore.EObject object, TypeContext context, java.util.List<net.ssehub.easy.varModel.model.Comment> comments)
      Creates a structured comment for the given object in context depending on the contents of comments, i.e.
      (package private) void error​(net.ssehub.easy.basics.messages.IIdentifiable exception, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causeFeature)
      Turns an IVML exception into a xText error.
      private boolean findOperation​(net.ssehub.easy.varModel.model.datatypes.IDatatype datatype, net.ssehub.easy.varModel.model.datatypes.Operation operation, boolean considerOperand)
      Finds an operation on a given datatype.
      private net.ssehub.easy.varModel.model.Comment handleBasicComment​(org.eclipse.emf.ecore.EObject object, TypeContext context)
      Handles the comments assigned to the EMF AST element object.
      protected void processAnnotation​(de.uni_hildesheim.sse.ivml.AnnotateTo annotation, TypeContext context)
      Processes an annotation.
      protected net.ssehub.easy.varModel.model.Attribute processAnnotation​(de.uni_hildesheim.sse.ivml.AnnotateTo annotation, java.lang.String name, TypeContext context, net.ssehub.easy.varModel.model.Attribute initial)
      Processes the annotation of name.
      private boolean processAttributeAssignment​(de.uni_hildesheim.sse.ivml.AttrAssignment assgn, TypeContext context, net.ssehub.easy.varModel.model.IDecisionVariableContainer parent, boolean process, boolean force)
      Processes an attribute assignment.
      private void processAttributeAssignmentExpressions​(java.util.List<de.uni_hildesheim.sse.ivml.AttrAssignment> assignments, TypeContext context)
      Processes all the expressions of attribute assignments.
      private void processAttributeAssignments​(java.util.List<de.uni_hildesheim.sse.ivml.AttrAssignment> assignments, TypeContext context, boolean force)
      Resolves attribute assignments.
      private boolean processCompound​(de.uni_hildesheim.sse.ivml.TypedefCompound tcomp, TypeContext context, boolean force)
      Processes a compound definition.
      protected void processConflict​(de.uni_hildesheim.sse.ivml.ConflictStmt conflictStmt, TypeContext context)
      Processes a conflict statement including import restrictions.
      private void processDefinitions​(java.util.List<de.uni_hildesheim.sse.ivml.Typedef> typedefs, java.util.List<de.uni_hildesheim.sse.ivml.VariableDeclaration> vardecls, java.util.List<de.uni_hildesheim.sse.ivml.AttrAssignment> assignments, TypeContext context, boolean force)
      Resolve dependencies among type definitions and resolve types in proper sequence.
      private void processEnum​(de.uni_hildesheim.sse.ivml.TypedefEnum tenum, TypeContext context)
      Processes an enum definition.
      protected void processEval​(de.uni_hildesheim.sse.ivml.Eval eval, TypeContext context, net.ssehub.easy.varModel.model.datatypes.Compound compound)
      Processes an evaluation block.
      private ModelTranslator.EvalBlockResult processEval​(de.uni_hildesheim.sse.ivml.Eval eval, net.ssehub.easy.varModel.model.IModelElement parent, TypeContext context)
      Process an eval block.
      private void processExpressions​(java.util.List<de.uni_hildesheim.sse.ivml.Typedef> typedefs, java.util.List<de.uni_hildesheim.sse.ivml.AttrAssignment> assignments, java.util.List<de.uni_hildesheim.sse.ivml.ExpressionStatement> exprs, TypeContext context)
      Processes all expressions at once and delegates to further processing methods.
      void processExpressionStatement​(de.uni_hildesheim.sse.ivml.ExpressionStatement statement, TypeContext context, net.ssehub.easy.varModel.model.IDecisionVariableContainer parent, boolean internal)
      Processes an expression statement and adds the result to the project in context.
      protected void processFreeze​(de.uni_hildesheim.sse.ivml.Freeze freeze, TypeContext context)
      Processes a freeze block.
      protected void processImport​(de.uni_hildesheim.sse.ivml.ImportStmt importStmt, TypeContext context)
      Processes an import statement including import restrictions.
      protected void processInterface​(de.uni_hildesheim.sse.ivml.InterfaceDeclaration eIface, TypeContext context)
      Processes an interface.
      private boolean processMapping​(de.uni_hildesheim.sse.ivml.TypedefMapping tmapping, TypeContext context, boolean force)
      Processes a typdef (type mapping).
      protected boolean processOpdef​(de.uni_hildesheim.sse.ivml.OpDefStatement op, TypeContext context, boolean force)
      Processes a custom operation definition and adds it to the type context.
      private net.ssehub.easy.varModel.cst.ConstraintSyntaxTree processOpDefImpl​(de.uni_hildesheim.sse.ivml.OpDefStatement op, TypeContext context, net.ssehub.easy.varModel.model.IModelElement parent)
      Processes an operation definition implementation.
      private void processOpDefs​(java.util.List<de.uni_hildesheim.sse.ivml.OpDefStatement> opDefs, TypeContext context)
      Resolve dependencies among operation definitions in proper sequence.
      private void processOpDefs​(java.util.List<de.uni_hildesheim.sse.ivml.OpDefStatement> opDefs, TypeContext context, boolean force)
      Resolves operation definitions.
      private void processTypeDefExpressions​(java.util.List<de.uni_hildesheim.sse.ivml.Typedef> typedefs, TypeContext context)
      Processes all the expressions of type definitions.
      private void processTypedefs​(java.util.List<de.uni_hildesheim.sse.ivml.Typedef> compounds, TypeContext context, boolean force)
      Resolves compound type definitions.
      private boolean processVariableDeclaration​(de.uni_hildesheim.sse.ivml.VariableDeclaration decl, TypeContext context, net.ssehub.easy.varModel.model.IDecisionVariableContainer container, boolean process, boolean force)
      Process variable declaration decl add IVML object model instances to project or compound.
      private void processVars​(java.util.List<de.uni_hildesheim.sse.ivml.VariableDeclaration> vars, TypeContext context, boolean force)
      Resolves variable declarations.
      private void resolveAssignments​(java.util.List<de.uni_hildesheim.sse.ivml.AttrAssignment> attrAssignments, TypeContext context, net.ssehub.easy.varModel.model.IDecisionVariableContainer parent, boolean force)
      Resolves the given assignments in attrAssignments.
      private void resolveDeclarations​(java.util.List<de.uni_hildesheim.sse.ivml.VariableDeclaration> varDecls, TypeContext context, net.ssehub.easy.varModel.model.IDecisionVariableContainer parent, boolean force)
      Resolves the given declarations in varDecl.
      private void resolveImports​(de.uni_hildesheim.sse.ivml.Project input, net.ssehub.easy.varModel.model.Project project, java.net.URI uri, java.util.List<de.uni_hildesheim.sse.ivml.Project> inProgress, net.ssehub.easy.basics.modelManagement.ImportResolver<net.ssehub.easy.varModel.model.Project> impResolver, boolean transitiveLoading)
      Resolve the imports.
      private java.lang.String toString​(java.util.List<de.uni_hildesheim.sse.ivml.VariableDeclarationPart> parts)
      Turns variable declaration parts into strings for debugging.
      private static java.lang.String unqualified​(net.ssehub.easy.varModel.model.datatypes.IDatatype type)
      Returns the unqualified name of type.
      private boolean variableDeclarationsResolvable​(java.util.List<de.uni_hildesheim.sse.ivml.VariableDeclaration> varDecls, TypeContext context, net.ssehub.easy.varModel.model.IDecisionVariableContainer parent, boolean force)
      Returns whether the declarations in varDecl can be resolved in the given context and the given parent container.
      (package private) void warning​(net.ssehub.easy.varModel.model.IvmlException exception, org.eclipse.emf.ecore.EObject cause, org.eclipse.emf.ecore.EStructuralFeature causeFeature)
      Turns an IVML exception into a xText warning.
      • 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 Detail

      • compoundMapping

        private java.util.Map<de.uni_hildesheim.sse.ivml.TypedefCompound,​net.ssehub.easy.varModel.model.datatypes.Compound> compoundMapping
      • assignmentMapping

        private java.util.Map<de.uni_hildesheim.sse.ivml.AttrAssignment,​net.ssehub.easy.varModel.model.AttributeAssignment> assignmentMapping
      • varMapping

        private java.util.Map<de.uni_hildesheim.sse.ivml.VariableDeclarationPart,​net.ssehub.easy.varModel.model.DecisionVariableDeclaration> varMapping
      • typedefMapping

        private java.util.Map<de.uni_hildesheim.sse.ivml.TypedefMapping,​net.ssehub.easy.varModel.model.datatypes.DerivedDatatype> typedefMapping
      • definitionsProcessed

        private java.util.Set<org.eclipse.emf.ecore.EObject> definitionsProcessed
      • onLoadMsgCleanupListener

        private net.ssehub.easy.basics.modelManagement.IModelProcessingListener<net.ssehub.easy.varModel.model.Project> onLoadMsgCleanupListener
      • expressionTranslator

        private ExpressionTranslator expressionTranslator
        Contains an expression translator instance. Expression are realized in an own class due to separation of concerns.
    • Constructor Detail

      • ModelTranslator

        public ModelTranslator()
        Creates a model translator instance.
    • Method Detail

      • createModel

        public ModelTranslator.Result createModel​(de.uni_hildesheim.sse.ivml.VariabilityUnit unit,
                                                  java.net.URI uri,
                                                  boolean registerSuccessful,
                                                  net.ssehub.easy.basics.modelManagement.ImportResolver<net.ssehub.easy.varModel.model.Project> impResolver)
        Creates a variability model from a given variability unit. This is the top-level entry method.
        Parameters:
        unit - the variability 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 in VarModel
        impResolver - the import resolver (may be null to use a new default import resolver)
        Returns:
        the corresponding variability model
      • createEmptyResult

        public ModelTranslator.Result createEmptyResult​(java.net.URI uri)
        Creates an empty result for failure cases.
        Parameters:
        uri - the model uri to identify this result/loader
        Returns:
        an empty result
      • handleBasicComment

        private net.ssehub.easy.varModel.model.Comment handleBasicComment​(org.eclipse.emf.ecore.EObject object,
                                                                          TypeContext context)
        Handles the comments assigned to the EMF AST element object.
        Parameters:
        object - the EMF AST element to analyze
        context - the parent context of the new comment in the IVML object model
        Returns:
        the resulting comment (may be null)
      • assignProjectComment

        private void assignProjectComment​(net.ssehub.easy.varModel.model.Project project,
                                          java.lang.Object element,
                                          net.ssehub.easy.varModel.model.Comment comment)
        Assigns a comment to an element directly assigned to a project and ensures the existence the structured comment for the project if required.
        Parameters:
        project - the project to assign to
        element - the element to assign to
        comment - the comment to be assigned
      • createProject

        private ResultEntry createProject​(de.uni_hildesheim.sse.ivml.Project project,
                                          java.net.URI uri,
                                          boolean registerSuccessful,
                                          java.util.List<de.uni_hildesheim.sse.ivml.Project> inProgress,
                                          net.ssehub.easy.basics.modelManagement.ImportResolver<net.ssehub.easy.varModel.model.Project> impResolver)
        Creates a variability model from a given ECore representation of a project. This method is intended as a second-level entry to the translation process.
        Parameters:
        project - the project 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 in VarModel
        inProgress - the projects currently being processed at once
        impResolver - the import resolver to use (may be null to use a new default import resolver)
        Returns:
        the corresponding IVML project
      • checkCompounds

        private void checkCompounds​(de.uni_hildesheim.sse.ivml.Project eProject,
                                    net.ssehub.easy.varModel.model.Project project)
        Checks the compounds in this project.
        Parameters:
        eProject - the AST project instance to check (fallback for messages)
        project - the corresponding IVML project instance
      • checkCompound

        private void checkCompound​(de.uni_hildesheim.sse.ivml.Project eProject,
                                   net.ssehub.easy.varModel.model.datatypes.Compound cmp,
                                   java.util.Map<net.ssehub.easy.varModel.model.datatypes.Compound,​de.uni_hildesheim.sse.ivml.TypedefCompound> cmpMapping,
                                   java.util.Map<java.lang.String,​net.ssehub.easy.varModel.model.DecisionVariableDeclaration> done)
        Checks the given compound. Due to the dynamic resolution sequence, we perform a post-check for hierarchical compound properties.
        Parameters:
        eProject - the AST project instance to check (fallback for messages)
        cmp - the compound to check
        cmpMapping - mapping between compounds and related AST objects for error identification
        done - already known/checked slot declarations
      • completeLoading

        void completeLoading​(ResultEntry entry)
        Complete loading of a given model.
        Parameters:
        entry - the result entry on which to complete loading
      • resolveImports

        private void resolveImports​(de.uni_hildesheim.sse.ivml.Project input,
                                    net.ssehub.easy.varModel.model.Project project,
                                    java.net.URI uri,
                                    java.util.List<de.uni_hildesheim.sse.ivml.Project> inProgress,
                                    net.ssehub.easy.basics.modelManagement.ImportResolver<net.ssehub.easy.varModel.model.Project> impResolver,
                                    boolean transitiveLoading)
        Resolve the imports.
        Parameters:
        input - the Ecore project representation
        project - the target project
        uri - the physical URI of the project
        inProgress - the other projects being resolved at once (in order to avoid loops)
        impResolver - the import resolver to use (may be null to use a new default import resolver)
        transitiveLoading - with or without transitive loading (false = lazy, true = force)
      • processExpressionStatement

        public void processExpressionStatement​(de.uni_hildesheim.sse.ivml.ExpressionStatement statement,
                                               TypeContext context,
                                               net.ssehub.easy.varModel.model.IDecisionVariableContainer parent,
                                               boolean internal)
                                        throws net.ssehub.easy.dslCore.translation.TranslatorException
        Processes an expression statement and adds the result to the project in context.
        Parameters:
        statement - the statement to process
        context - the type context to be considered
        parent - the actual (intended) parent of the constraint to be created
        internal - whether the constraint to be created is internal (and shall not be visible to the user)
        Throws:
        net.ssehub.easy.dslCore.translation.TranslatorException - in case that the processing of the statement was terminated abnormally
      • processExpressions

        private void processExpressions​(java.util.List<de.uni_hildesheim.sse.ivml.Typedef> typedefs,
                                        java.util.List<de.uni_hildesheim.sse.ivml.AttrAssignment> assignments,
                                        java.util.List<de.uni_hildesheim.sse.ivml.ExpressionStatement> exprs,
                                        TypeContext context)
        Processes all expressions at once and delegates to further processing methods.
        Parameters:
        typedefs - the type definitions for which expressions shall be resolved
        assignments - the attribute assignments for which expressions shall be resolved
        exprs - the expressions to be resolved
        context - the type resolution context
        See Also:
        processAttributeAssignmentExpressions(List, TypeContext), processTypeDefExpressions(List, TypeContext)
      • processTypeDefExpressions

        private void processTypeDefExpressions​(java.util.List<de.uni_hildesheim.sse.ivml.Typedef> typedefs,
                                               TypeContext context)
        Processes all the expressions of type definitions.
        Parameters:
        typedefs - the type definitions for which expressions shall be resolved
        context - the type resolution context
        See Also:
        processExpressions(List, List, List, TypeContext)
      • processAttributeAssignmentExpressions

        private void processAttributeAssignmentExpressions​(java.util.List<de.uni_hildesheim.sse.ivml.AttrAssignment> assignments,
                                                           TypeContext context)
        Processes all the expressions of attribute assignments.
        Parameters:
        assignments - the attribute assignments for which expressions shall be resolved
        context - the type resolution context
        See Also:
        processExpressions(List, List, List, TypeContext)
      • processDefinitions

        private void processDefinitions​(java.util.List<de.uni_hildesheim.sse.ivml.Typedef> typedefs,
                                        java.util.List<de.uni_hildesheim.sse.ivml.VariableDeclaration> vardecls,
                                        java.util.List<de.uni_hildesheim.sse.ivml.AttrAssignment> assignments,
                                        TypeContext context,
                                        boolean force)
        Resolve dependencies among type definitions and resolve types in proper sequence.
        Parameters:
        typedefs - the type definitions
        vardecls - the variable declarations
        assignments - the assignments
        context - the type resolution context
        force - if creation (and related errors) shall be forced or just tested and created on best-effort
      • processOpDefs

        private void processOpDefs​(java.util.List<de.uni_hildesheim.sse.ivml.OpDefStatement> opDefs,
                                   TypeContext context)
        Resolve dependencies among operation definitions in proper sequence.
        Parameters:
        opDefs - the operation definitions
        context - the type resolution context
      • processOpDefs

        private void processOpDefs​(java.util.List<de.uni_hildesheim.sse.ivml.OpDefStatement> opDefs,
                                   TypeContext context,
                                   boolean force)
        Resolves operation definitions.
        Parameters:
        opDefs - the operation definitions to be resolved (to be modified as a side effect)
        context - the type context
        force - if creation (and related errors) shall be forced or just tested
      • processTypedefs

        private void processTypedefs​(java.util.List<de.uni_hildesheim.sse.ivml.Typedef> compounds,
                                     TypeContext context,
                                     boolean force)
        Resolves compound type definitions.
        Parameters:
        compounds - the compounds to be resolved (to be modified as a side effect)
        context - the type context
        force - if creation (and related errors) shall be forced or just tested
      • processVars

        private void processVars​(java.util.List<de.uni_hildesheim.sse.ivml.VariableDeclaration> vars,
                                 TypeContext context,
                                 boolean force)
        Resolves variable declarations.
        Parameters:
        vars - the variables types to be resolved (to be modified as a side effect)
        context - the type context
        force - if creation (and related errors) shall be forced
      • processAttributeAssignments

        private void processAttributeAssignments​(java.util.List<de.uni_hildesheim.sse.ivml.AttrAssignment> assignments,
                                                 TypeContext context,
                                                 boolean force)
        Resolves attribute assignments.
        Parameters:
        assignments - the attribute assignments to be resolved (to be modified as a side effect)
        context - the type context
        force - if creation (and related errors) shall be forced
      • toString

        private java.lang.String toString​(java.util.List<de.uni_hildesheim.sse.ivml.VariableDeclarationPart> parts)
        Turns variable declaration parts into strings for debugging.
        Parameters:
        parts - the parts
        Returns:
        the names
      • processVariableDeclaration

        private boolean processVariableDeclaration​(de.uni_hildesheim.sse.ivml.VariableDeclaration decl,
                                                   TypeContext context,
                                                   net.ssehub.easy.varModel.model.IDecisionVariableContainer container,
                                                   boolean process,
                                                   boolean force)
                                            throws net.ssehub.easy.dslCore.translation.TranslatorException
        Process variable declaration decl add IVML object model instances to project or compound.
        Parameters:
        decl - the variable declarations in the project
        context - the resolution context
        container - optional element to add the instances to instead of project
        process - false if the declaration shall not be created but only tested first, true if creation should be done in case that the variable declaration can be processed
        force - process anyway, don't test
        Returns:
        true if the base type is yet available and the remaining type resolution was done, false if this typedef can actually not be processed
        Throws:
        net.ssehub.easy.dslCore.translation.TranslatorException - in case of any problem during the translation
      • alreadyDefinedError

        private void alreadyDefinedError​(java.lang.String name,
                                         org.eclipse.emf.ecore.EObject object,
                                         org.eclipse.emf.ecore.EStructuralFeature feature)
                                  throws net.ssehub.easy.dslCore.translation.TranslatorException
        Emits an already defined error.
        Parameters:
        name - the already defined name
        object - the causing Ecore object
        feature - the causing feature
        Throws:
        net.ssehub.easy.dslCore.translation.TranslatorException - the corresponding exception always
      • processOpdef

        protected boolean processOpdef​(de.uni_hildesheim.sse.ivml.OpDefStatement op,
                                       TypeContext context,
                                       boolean force)
                                throws net.ssehub.easy.dslCore.translation.TranslatorException
        Processes a custom operation definition and adds it to the type context.
        Parameters:
        op - the operation definition
        context - the type context to be considered
        force - if creation (and related errors) shall be forced or just tested
        Returns:
        true if processing was successful, false if (typically) a function is called which is currently not defined.
        Throws:
        net.ssehub.easy.dslCore.translation.TranslatorException - in case that the processing of the statement must be terminated abnormally
      • unqualified

        private static java.lang.String unqualified​(net.ssehub.easy.varModel.model.datatypes.IDatatype type)
        Returns the unqualified name of type.
        Parameters:
        type - the type
        Returns:
        the unqualified name
      • checkDefaultParamSequence

        private void checkDefaultParamSequence​(de.uni_hildesheim.sse.ivml.OpDefStatement op,
                                               net.ssehub.easy.varModel.model.DecisionVariableDeclaration[] param)
        Checks the sequence of default and non-default parameters.
        Parameters:
        op - the operation declaration
        param - the parameters to check
      • processOpDefImpl

        private net.ssehub.easy.varModel.cst.ConstraintSyntaxTree processOpDefImpl​(de.uni_hildesheim.sse.ivml.OpDefStatement op,
                                                                                   TypeContext context,
                                                                                   net.ssehub.easy.varModel.model.IModelElement parent)
                                                                            throws net.ssehub.easy.dslCore.translation.TranslatorException
        Processes an operation definition implementation.
        Parameters:
        op - the operation definition
        context - the type context
        parent - the parent model element
        Returns:
        the implementing constraint syntax tree
        Throws:
        net.ssehub.easy.dslCore.translation.TranslatorException - in case that the processing of the op must be terminated abnormally
      • processInterface

        protected void processInterface​(de.uni_hildesheim.sse.ivml.InterfaceDeclaration eIface,
                                        TypeContext context)
        Processes an interface. In case of success, the interface will be added to the project in context.
        Parameters:
        eIface - the interface to be processed
        context - the type context to be considered
      • processAnnotation

        protected void processAnnotation​(de.uni_hildesheim.sse.ivml.AnnotateTo annotation,
                                         TypeContext context)
        Processes an annotation. In case of success, the annotation will be applied.
        Parameters:
        annotation - the interface to be processed
        context - the type context to be considered
      • processAnnotation

        protected net.ssehub.easy.varModel.model.Attribute processAnnotation​(de.uni_hildesheim.sse.ivml.AnnotateTo annotation,
                                                                             java.lang.String name,
                                                                             TypeContext context,
                                                                             net.ssehub.easy.varModel.model.Attribute initial)
        Processes the annotation of name. In case of success, the annotation will be applied.
        Parameters:
        annotation - the annotation to be processed
        name - the name of the annotated element
        context - the type context to be considered
        initial - the initial attribute created in series
        Returns:
        the created attribute or null
      • findOperation

        private boolean findOperation​(net.ssehub.easy.varModel.model.datatypes.IDatatype datatype,
                                      net.ssehub.easy.varModel.model.datatypes.Operation operation,
                                      boolean considerOperand)
        Finds an operation on a given datatype.
        Parameters:
        datatype - the datatype to search for
        operation - the operation to be searched for
        considerOperand - whether the operand of the operations defined in datatype should be considered as first parameter of operation, used to match the implicit project parameter for ambigous operation checking
        Returns:
        true if the operation was found, false else
      • processEnum

        private void processEnum​(de.uni_hildesheim.sse.ivml.TypedefEnum tenum,
                                 TypeContext context)
                          throws net.ssehub.easy.dslCore.translation.TranslatorException
        Processes an enum definition.
        Parameters:
        tenum - the type definition for the enum
        context - the type context to be considered
        Throws:
        net.ssehub.easy.dslCore.translation.TranslatorException - in case that the processing of the statement must be terminated abnormally
      • processCompound

        private boolean processCompound​(de.uni_hildesheim.sse.ivml.TypedefCompound tcomp,
                                        TypeContext context,
                                        boolean force)
                                 throws net.ssehub.easy.dslCore.translation.TranslatorException
        Processes a compound definition.
        Parameters:
        tcomp - the type definition for the compound
        context - the type context to be considered
        force - creation, don't check before
        Returns:
        true if the base type is yet available and the remaining type resolution was done, false if this typedef can actually not be processed
        Throws:
        net.ssehub.easy.dslCore.translation.TranslatorException - in case that the processing of the tcomp must be terminated abnormally due to type problems
      • processAttributeAssignment

        private boolean processAttributeAssignment​(de.uni_hildesheim.sse.ivml.AttrAssignment assgn,
                                                   TypeContext context,
                                                   net.ssehub.easy.varModel.model.IDecisionVariableContainer parent,
                                                   boolean process,
                                                   boolean force)
                                            throws net.ssehub.easy.dslCore.translation.TranslatorException
        Processes an attribute assignment.
        Parameters:
        assgn - the attribute assignment
        context - the type context to be considered
        parent - the parent container
        process - the assignment or do only type resolution
        force - creation, don't check before
        Returns:
        true if the base types is yet available and the remaining type resolution was done, false if this assignment can actually not be processed
        Throws:
        net.ssehub.easy.dslCore.translation.TranslatorException - in case that the processing of the assgn must be terminated abnormally due to type problems
      • variableDeclarationsResolvable

        private boolean variableDeclarationsResolvable​(java.util.List<de.uni_hildesheim.sse.ivml.VariableDeclaration> varDecls,
                                                       TypeContext context,
                                                       net.ssehub.easy.varModel.model.IDecisionVariableContainer parent,
                                                       boolean force)
                                                throws net.ssehub.easy.dslCore.translation.TranslatorException
        Returns whether the declarations in varDecl can be resolved in the given context and the given parent container.
        Parameters:
        varDecls - the variable declarations to be resolved
        context - the type context
        parent - the parent the varDecls shall be inserted into
        force - creation, don't check before
        Returns:
        true if the declarations are resolvable, false else
        Throws:
        net.ssehub.easy.dslCore.translation.TranslatorException - in case of type problems, resolution problems or type incompatibilities
      • attributeAssignmentsResolvable

        private boolean attributeAssignmentsResolvable​(java.util.List<de.uni_hildesheim.sse.ivml.AttrAssignment> attrAssignments,
                                                       TypeContext context,
                                                       net.ssehub.easy.varModel.model.IDecisionVariableContainer parent,
                                                       boolean force)
                                                throws net.ssehub.easy.dslCore.translation.TranslatorException
        Returns whether the assignments in attrAssignments can be resolved in the given context and the given parent container.
        Parameters:
        attrAssignments - the assignments to be resolved
        context - the type context
        parent - the parent the varDecls shall be inserted into
        force - creation, don't check before
        Returns:
        true if the declarations are resolvable, false else
        Throws:
        net.ssehub.easy.dslCore.translation.TranslatorException - in case of type problems, resolution problems or type incompatibilities
      • resolveDeclarations

        private void resolveDeclarations​(java.util.List<de.uni_hildesheim.sse.ivml.VariableDeclaration> varDecls,
                                         TypeContext context,
                                         net.ssehub.easy.varModel.model.IDecisionVariableContainer parent,
                                         boolean force)
                                  throws net.ssehub.easy.dslCore.translation.TranslatorException
        Resolves the given declarations in varDecl.
        Parameters:
        varDecls - the variable declarations to be resolved
        context - the type context
        parent - the parent the varDecls shall be inserted into
        force - creation, don't check before
        Throws:
        net.ssehub.easy.dslCore.translation.TranslatorException - in case of type problems, resolution problems or type incompatibilities
      • resolveAssignments

        private void resolveAssignments​(java.util.List<de.uni_hildesheim.sse.ivml.AttrAssignment> attrAssignments,
                                        TypeContext context,
                                        net.ssehub.easy.varModel.model.IDecisionVariableContainer parent,
                                        boolean force)
                                 throws net.ssehub.easy.dslCore.translation.TranslatorException
        Resolves the given assignments in attrAssignments.
        Parameters:
        attrAssignments - the assignments to be resolved
        context - the type context
        parent - the parent the attrAssignments shall be inserted into
        force - creation, don't check before
        Throws:
        net.ssehub.easy.dslCore.translation.TranslatorException - in case of type problems, resolution problems or type incompatibilities
      • processMapping

        private boolean processMapping​(de.uni_hildesheim.sse.ivml.TypedefMapping tmapping,
                                       TypeContext context,
                                       boolean force)
                                throws net.ssehub.easy.dslCore.translation.TranslatorException
        Processes a typdef (type mapping).
        Parameters:
        tmapping - the type mapping definition
        context - the type context to be considered
        force - if creation (and related errors) shall be forced or just tested
        Returns:
        true if the base type is yet available and the remaining type resolution was done, false if this typedef can actually not be processed
        Throws:
        net.ssehub.easy.dslCore.translation.TranslatorException - in case that the processing of the statement must be terminated abnormally
      • processEval

        protected void processEval​(de.uni_hildesheim.sse.ivml.Eval eval,
                                   TypeContext context,
                                   net.ssehub.easy.varModel.model.datatypes.Compound compound)
        Processes an evaluation block. In case of errors the respective element is not added to the resulting project.
        Parameters:
        eval - the evaluation block
        context - the context for type resolution
        compound - optional compound to add the eval block to, null for adding it to the actual project in context
      • processEval

        private ModelTranslator.EvalBlockResult processEval​(de.uni_hildesheim.sse.ivml.Eval eval,
                                                            net.ssehub.easy.varModel.model.IModelElement parent,
                                                            TypeContext context)
        Process an eval block.
        Parameters:
        eval - the evaluation block
        parent - the parent element
        context - the context for type resolution
        Returns:
        result of processing an eval block
      • processFreeze

        protected void processFreeze​(de.uni_hildesheim.sse.ivml.Freeze freeze,
                                     TypeContext context)
        Processes a freeze block. In case of errors the respective element is not added to the resulting project.
        Parameters:
        freeze - the freeze block
        context - the type context to be considered
      • createStructuredComment

        private net.ssehub.easy.varModel.model.StructuredComment createStructuredComment​(org.eclipse.emf.ecore.EObject object,
                                                                                         TypeContext context,
                                                                                         java.util.List<net.ssehub.easy.varModel.model.Comment> comments)
        Creates a structured comment for the given object in context depending on the contents of comments, i.e. whether there are comments or not.
        Parameters:
        object - the EObject to create the comment for
        context - the type context to assign the created context to
        comments - the comments to consider
        Returns:
        the created comment object or null
      • assignComments

        private void assignComments​(net.ssehub.easy.varModel.model.StructuredComment target,
                                    java.util.List<?> elements,
                                    java.util.List<net.ssehub.easy.varModel.model.Comment> comments,
                                    net.ssehub.easy.varModel.model.IModelElement parent)
        Assigns the comments in comments to the corresponding model elements in elements.
        Parameters:
        target - the structured comment to store the mapping in
        elements - the elements to be assigned to the comments
        comments - the comments (must be of same size)
        parent - the explicit parent element of the comments
      • processImport

        protected void processImport​(de.uni_hildesheim.sse.ivml.ImportStmt importStmt,
                                     TypeContext context)
        Processes an import statement including import restrictions. In case of errors the respective element is not added to the resulting project.
        Parameters:
        importStmt - the import statement
        context - the type context to be considered
      • processConflict

        protected void processConflict​(de.uni_hildesheim.sse.ivml.ConflictStmt conflictStmt,
                                       TypeContext context)
        Processes a conflict statement including import restrictions. In case of errors the respective element is not added to the resulting project.
        Parameters:
        conflictStmt - the conflict statement
        context - the type context to be considered
      • error

        void error​(net.ssehub.easy.basics.messages.IIdentifiable exception,
                   org.eclipse.emf.ecore.EObject cause,
                   org.eclipse.emf.ecore.EStructuralFeature causeFeature)
        Turns an IVML 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 as an appropriate constant from IvmlPackage.Literals
      • warning

        void warning​(net.ssehub.easy.varModel.model.IvmlException exception,
                     org.eclipse.emf.ecore.EObject cause,
                     org.eclipse.emf.ecore.EStructuralFeature causeFeature)
        Turns an IVML 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 as an appropriate constant from IvmlPackage.Literals