Class AbstractModelTranslator<M extends net.ssehub.easy.instantiation.core.model.buildlangModel.Script,L extends LanguageUnit>

java.lang.Object
net.ssehub.easy.dslCore.translation.MessageReceiver
net.ssehub.easy.dslCore.translation.ModelTranslator<ExpressionTranslator>
de.uni_hildesheim.sse.vil.expressions.translation.ModelTranslator<M,net.ssehub.easy.instantiation.core.model.buildlangModel.VariableDeclaration,net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver,net.ssehub.easy.instantiation.core.model.buildlangModel.ExpressionStatement,ExpressionTranslator>
de.uni_hildesheim.sse.buildLanguageTranslation.AbstractModelTranslator<M,L>
All Implemented Interfaces:
net.ssehub.easy.dslCore.translation.IMessageReceiver
Direct Known Subclasses:
ModelTranslator

public abstract class AbstractModelTranslator<M extends net.ssehub.easy.instantiation.core.model.buildlangModel.Script,L extends LanguageUnit> extends de.uni_hildesheim.sse.vil.expressions.translation.ModelTranslator<M,net.ssehub.easy.instantiation.core.model.buildlangModel.VariableDeclaration,net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver,net.ssehub.easy.instantiation.core.model.buildlangModel.ExpressionStatement,ExpressionTranslator>
Implements the translation from the DSL to the build model in the instantiator core. This class is intended for reuse.
Author:
Holger Eichelberger
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected class 
    AbstractModelTranslator.AbstractRuleTranslator<D extends org.eclipse.emf.ecore.EObject,R extends net.ssehub.easy.instantiation.core.model.buildlangModel.Rule>
    An extensible rule translator.
    protected class 
    Implements a translator for VIL rules.
  • Field Summary

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

    Constructors
    Modifier
    Constructor
    Description
     
    Creates a model translator.
    protected
    AbstractModelTranslator(ExpressionTranslator expressionTranslator, net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver resolver)
    Creates a model translator.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    addVisibleDeclarationsToResolver(M model, net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver resolver)
     
    protected void
    checkConstants(net.ssehub.easy.instantiation.core.model.buildlangModel.Script project, L cause)
    Performs static tests on the constants.
    protected net.ssehub.easy.instantiation.core.model.buildlangModel.VariableDeclaration[]
    createArray(int len)
     
    protected net.ssehub.easy.instantiation.core.model.buildlangModel.Compound
    createCompound(net.ssehub.easy.instantiation.core.model.vilTypes.CompoundTypeDescriptor type)
     
    protected abstract M
    createScript(String name, net.ssehub.easy.basics.modelManagement.ModelImport<M> parent, net.ssehub.easy.instantiation.core.model.buildlangModel.Script.ScriptDescriptor<M> descriptor, net.ssehub.easy.instantiation.core.model.vilTypes.TypeRegistry registry)
    Creates a script instance.
    protected M
    createScript(L script, URI uri, boolean registerSuccessful, List<LanguageUnit> inProgress, net.ssehub.easy.instantiation.core.model.buildlangModel.Imports<M> imports, net.ssehub.easy.basics.modelManagement.ImportResolver<M> impResolver)
    Creates a script instance from an EMF instance.
    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.
    protected List<org.eclipse.emf.ecore.EObject>
    getContents(L script)
    Returns the actual contents of script.
    protected abstract net.ssehub.easy.basics.modelManagement.ModelManagement<M>
    Returns the management instance.
    protected abstract net.ssehub.easy.basics.modelManagement.IModelLoader<M>
     
    private static boolean
    Returns whether a rule is protected.
    protected void
    processAdditionalContents(L unit, List<org.eclipse.emf.ecore.EObject> elements, M result)
    protected void
    processContents(L script, M result)
    Processes the contents of a language unit and stores the results in result.
    protected void
    processGlobalVariableDeclarations(List<org.eclipse.emf.ecore.EObject> elts, M result)
    Processes the global script variable declarations.
    protected net.ssehub.easy.instantiation.core.model.buildlangModel.Imports<M>
    processImports(org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vil.expressions.expressionDsl.Import> imports, org.eclipse.emf.common.util.EList<Require> requires)
    Processes the imports and returns an summarizing instance.
    protected void
    Re-processes global variable declarations to get rid of temporary "function pointer" expressions.
    private List<net.ssehub.easy.instantiation.core.model.expressions.Expression>
    resolveExpressions(org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vil.expressions.expressionDsl.LogicalExpression> expressions)
    Resolves a set of expressions.
    private void
    resolveRuleExpressions(net.ssehub.easy.instantiation.core.model.buildlangModel.RuleDescriptor descriptor, net.ssehub.easy.instantiation.core.model.buildlangModel.Rule.Side side, org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vil.expressions.expressionDsl.LogicalExpression> expressions)
    Resolves rule 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

  • Constructor Details

    • AbstractModelTranslator

      public AbstractModelTranslator()
      Creates a model translator.
    • AbstractModelTranslator

      protected AbstractModelTranslator(ExpressionTranslator expressionTranslator, net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver resolver)
      Creates a model translator.
      Parameters:
      expressionTranslator - the expression translator to use
      resolver - the resolver to use
  • Method Details

    • createScript

      protected M createScript(L script, URI uri, boolean registerSuccessful, List<LanguageUnit> inProgress, net.ssehub.easy.instantiation.core.model.buildlangModel.Imports<M> imports, net.ssehub.easy.basics.modelManagement.ImportResolver<M> impResolver) throws net.ssehub.easy.dslCore.translation.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:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that a problem occurred
    • processContents

      protected void processContents(L script, M result) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Processes the contents of a language unit and stores the results in result. Calls
      invalid reference
      #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:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that processing fails
    • processGlobalVariableDeclarations

      protected void processGlobalVariableDeclarations(List<org.eclipse.emf.ecore.EObject> elts, M result)
      Processes the global script variable declarations.
      Parameters:
      result - the result instance to be modified
      script - the script language unit to be processed
    • 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 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, List<org.eclipse.emf.ecore.EObject> elements, M result) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Parameters:
      unit - the language unit to process
      result - the result instance to be modified
      script - the script language unit to be processed
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that processing fails
    • createScript

      protected abstract M createScript(String name, net.ssehub.easy.basics.modelManagement.ModelImport<M> parent, net.ssehub.easy.instantiation.core.model.buildlangModel.Script.ScriptDescriptor<M> descriptor, net.ssehub.easy.instantiation.core.model.vilTypes.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 net.ssehub.easy.instantiation.core.model.buildlangModel.Imports<M> processImports(org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vil.expressions.expressionDsl.Import> imports, org.eclipse.emf.common.util.EList<Require> requires) throws net.ssehub.easy.dslCore.translation.TranslatorException
      Processes the imports and returns an summarizing instance.
      Parameters:
      imports - the imports to be processed
      Returns:
      the summarizing instance
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that processing the imports fails
    • getManagementInstance

      protected abstract net.ssehub.easy.basics.modelManagement.ModelManagement<M> getManagementInstance()
      Returns the management instance.
      Specified by:
      getManagementInstance in class de.uni_hildesheim.sse.vil.expressions.translation.ModelTranslator<M extends net.ssehub.easy.instantiation.core.model.buildlangModel.Script,net.ssehub.easy.instantiation.core.model.buildlangModel.VariableDeclaration,net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver,net.ssehub.easy.instantiation.core.model.buildlangModel.ExpressionStatement,ExpressionTranslator>
      Returns:
      the management instance
    • getModelLoader

      protected abstract net.ssehub.easy.basics.modelManagement.IModelLoader<M> getModelLoader()
    • checkConstants

      protected void checkConstants(net.ssehub.easy.instantiation.core.model.buildlangModel.Script project, L cause)
      Performs static tests on the constants.
      Parameters:
      project - the project created
      cause - the causing ECore element
      Throws:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case that a problem occurred
    • resolveExpressions

      private List<net.ssehub.easy.instantiation.core.model.expressions.Expression> resolveExpressions(org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vil.expressions.expressionDsl.LogicalExpression> expressions) throws net.ssehub.easy.dslCore.translation.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:
      net.ssehub.easy.dslCore.translation.TranslatorException
    • resolveRuleExpressions

      private void resolveRuleExpressions(net.ssehub.easy.instantiation.core.model.buildlangModel.RuleDescriptor descriptor, net.ssehub.easy.instantiation.core.model.buildlangModel.Rule.Side side, org.eclipse.emf.common.util.EList<de.uni_hildesheim.sse.vil.expressions.expressionDsl.LogicalExpression> expressions) throws net.ssehub.easy.dslCore.translation.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:
      net.ssehub.easy.dslCore.translation.TranslatorException - in case of resolution problems
    • createArray

      protected net.ssehub.easy.instantiation.core.model.buildlangModel.VariableDeclaration[] createArray(int len)
      Specified by:
      createArray in class de.uni_hildesheim.sse.vil.expressions.translation.ModelTranslator<M extends net.ssehub.easy.instantiation.core.model.buildlangModel.Script,net.ssehub.easy.instantiation.core.model.buildlangModel.VariableDeclaration,net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver,net.ssehub.easy.instantiation.core.model.buildlangModel.ExpressionStatement,ExpressionTranslator>
    • isProtected

      private static boolean isProtected(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(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 cause of the feature
    • 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 cause of the feature
    • addVisibleDeclarationsToResolver

      protected void addVisibleDeclarationsToResolver(M model, net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver resolver)
      Specified by:
      addVisibleDeclarationsToResolver in class de.uni_hildesheim.sse.vil.expressions.translation.ModelTranslator<M extends net.ssehub.easy.instantiation.core.model.buildlangModel.Script,net.ssehub.easy.instantiation.core.model.buildlangModel.VariableDeclaration,net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver,net.ssehub.easy.instantiation.core.model.buildlangModel.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<M extends net.ssehub.easy.instantiation.core.model.buildlangModel.Script,net.ssehub.easy.instantiation.core.model.buildlangModel.VariableDeclaration,net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver,net.ssehub.easy.instantiation.core.model.buildlangModel.ExpressionStatement,ExpressionTranslator>
      Throws:
      net.ssehub.easy.instantiation.core.model.common.VilException
    • createCompound

      protected net.ssehub.easy.instantiation.core.model.buildlangModel.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<M extends net.ssehub.easy.instantiation.core.model.buildlangModel.Script,net.ssehub.easy.instantiation.core.model.buildlangModel.VariableDeclaration,net.ssehub.easy.instantiation.core.model.buildlangModel.Resolver,net.ssehub.easy.instantiation.core.model.buildlangModel.ExpressionStatement,ExpressionTranslator>
      Throws:
      net.ssehub.easy.instantiation.core.model.common.VilException