Class RewriteContext

java.lang.Object
net.ssehub.easy.varModel.model.rewrite.RewriteContext

public class RewriteContext extends Object
Used as part of ProjectRewriteVisitor to store translated Objects.
Author:
El-Sharkawy
  • Field Details

    • projectQualifier

      private Set<String> projectQualifier
      Set of identifiers (name + version) of projects which will be kept. Needed for removal of elements, which belong to a removed import. A string is used instead of projects to simplify comparison if references change...
    • removedElements

      private Map<Class<?>,Set<ContainableModelElement>> removedElements
    • elementsOfRemovedImports

      private Map<String,List<ContainableModelElement>> elementsOfRemovedImports
      Elements of a removed import. As long as it is unclear whether another project is till importing this project, the elements cannot be removed. At the end of visitation, this map can be used to cleanup the main project.
    • elementsWereRemoved

      private boolean elementsWereRemoved
    • variablesTable

      private VariableLookUpTable variablesTable
  • Constructor Details

    • RewriteContext

      protected RewriteContext()
      Avoid instantiation from outside.
  • Method Details

    • getLookUpTable

      VariableLookUpTable getLookUpTable()
      Getter for the VariableLookUpTable, for initialization inside the visitor.
      Returns:
      The (empty) VariableLookUpTable.
    • generateQualifiedName

      private String generateQualifiedName(Project project)
      Returns the qualified name of a project as unique identifier for comparison whether the project was deleted.
      Parameters:
      project - The project for which the qualified name shall be generated.
      Returns:
      projectName[+Version].
    • removeElement

      public void removeElement(ContainableModelElement removedElememt)
      Stores the information that a model element was removed. Helpful for removing all instances pointing to this variable.
      Parameters:
      removedElememt - The removed element.
    • elementWasRemoved

      public boolean elementWasRemoved(ContainableModelElement elememt)
      Returns whether the given element was removed from the project.
      Parameters:
      elememt - An element to test.
      Returns:
      true if the element was removed, false if the element still exist.
    • hasRemovedElementsOfType

      public boolean hasRemovedElementsOfType(Class<? extends ContainableModelElement> type)
      Checks whether elements of the given ContainableModelElement was removed.
      Parameters:
      type - A class, visited by IModelVisitor.
      Returns:
      true if at least one element of this class was removed.
    • elementesWereRemoved

      public boolean elementesWereRemoved()
      Returns whether elements were removed during the last iteration.
      Returns:
      true if at least one element was removed, false otherwise.
    • clear

      void clear()
      Resets the internal temporary knowledge if the same projects should be filtered a second time.
    • newRun

      void newRun()
      Resets the internal temporary knowledge if anew project should be filtered based on the knowledge of a previous filtering.
    • projectIsStillPresent

      public boolean projectIsStillPresent(Project project)
      Tests whether the project is still part of the main project (via an import).
      Parameters:
      project - The project to test
      Returns:
      trueproject is still part of the main project, false it is unclear.
    • markForImportRemoval

      void markForImportRemoval(Project declaringProject, ContainableModelElement nestedElement)
      Marks an element of an imported project for removal if the related ProjectImport was deleted.
      Parameters:
      declaringProject - The project were the element was created.
      nestedElement - The element itself.
    • removeElementsOfRemovedImports

      void removeElementsOfRemovedImports()
      Removes elements of removed ProjectImport, must be called after the ProjectRewriteVisitor is finished with a complete visitation iteration and before clear().
    • getInstancesForType

      public Set<IDecisionVariable> getInstancesForType(Configuration config, IDatatype type)
      Returns the set of instances of the given IDatatype.
      Parameters:
      config - The configuration which is used to retrieve all IDecisionVariables.
      type - The exact IDatatype for which the instances shall be returned, will not consider IDatatype.isAssignableFrom(IDatatype).
      Returns:
      The instances for the given type or null if no instances exist.
    • getInstancesForDeclaration

      public Set<IDecisionVariable> getInstancesForDeclaration(Configuration config, AbstractVariable declaration)
      Returns the set of instances of the given AbstractVariable declaration.
      Parameters:
      config - The configuration which is used to retrieve all IDecisionVariables.
      declaration - The declaration for which the instances shall be returned. If the declaration is nested inside a compound which was multiple times instantiated, this single declaration could return multiple IDecisionVariables.
      Returns:
      The instances for the given declaration or null if no instances exist.
    • declarationKnown

      boolean declarationKnown(AbstractVariable declaration)
      Checks whether the declaration is known or whether the declaration is a local declaration used as an iterator of a constraint. Needs that the internal VariableLookUpTable was already initialized with a Configuration.
      Parameters:
      declaration - The declaration to check.
      Returns:
      true if the declaration is used for a IDecisionVariable of the configuration or if the internal table was not initialized with a Configuration, false otherwise.
    • addUsedProject

      public void addUsedProject(Project project)
      Marks that a project was used, i.e., is still part of the overall structure and should not be removed.
      Parameters:
      project - A visited project, which is may be imported.
      See Also: