Class RewriteContext
java.lang.Object
net.ssehub.easy.varModel.model.rewrite.RewriteContext
Used as part of
ProjectRewriteVisitor to store translated Objects.- Author:
- El-Sharkawy
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Map<String, List<ContainableModelElement>> Elements of a removed import.private booleanSet of identifiers (name + version) of projects which will be kept.private Map<Class<?>, Set<ContainableModelElement>> private VariableLookUpTable -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddUsedProject(Project project) Marks that a project was used, i.e., is still part of the overall structure and should not be removed.(package private) voidclear()Resets the internal temporary knowledge if the same projects should be filtered a second time.(package private) booleandeclarationKnown(AbstractVariable declaration) Checks whether the declaration is known or whether the declaration is a local declaration used as an iterator of a constraint.booleanReturns whether elements were removed during the last iteration.booleanelementWasRemoved(ContainableModelElement elememt) Returns whether the given element was removed from the project.private StringgenerateQualifiedName(Project project) Returns the qualified name of a project as unique identifier for comparison whether the project was deleted.getInstancesForDeclaration(Configuration config, AbstractVariable declaration) Returns the set of instances of the givenAbstractVariabledeclaration.getInstancesForType(Configuration config, IDatatype type) Returns the set of instances of the givenIDatatype.(package private) VariableLookUpTableGetter for theVariableLookUpTable, for initialization inside the visitor.booleanhasRemovedElementsOfType(Class<? extends ContainableModelElement> type) Checks whether elements of the givenContainableModelElementwas removed.(package private) voidmarkForImportRemoval(Project declaringProject, ContainableModelElement nestedElement) Marks an element of an imported project for removal if the relatedProjectImportwas deleted.(package private) voidnewRun()Resets the internal temporary knowledge if anew project should be filtered based on the knowledge of a previous filtering.booleanprojectIsStillPresent(Project project) Tests whether the project is still part of the main project (via an import).voidremoveElement(ContainableModelElement removedElememt) Stores the information that a model element was removed.(package private) voidRemoves elements of removedProjectImport, must be called after theProjectRewriteVisitoris finished with a complete visitation iteration and beforeclear().
-
Field Details
-
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
-
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
-
-
Constructor Details
-
RewriteContext
protected RewriteContext()Avoid instantiation from outside.
-
-
Method Details
-
getLookUpTable
VariableLookUpTable getLookUpTable()Getter for theVariableLookUpTable, for initialization inside the visitor.- Returns:
- The (empty)
VariableLookUpTable.
-
generateQualifiedName
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
Stores the information that a model element was removed. Helpful for removing all instances pointing to this variable.- Parameters:
removedElememt- The removed element.
-
elementWasRemoved
Returns whether the given element was removed from the project.- Parameters:
elememt- An element to test.- Returns:
trueif the element was removed,falseif the element still exist.
-
hasRemovedElementsOfType
Checks whether elements of the givenContainableModelElementwas removed.- Parameters:
type- A class, visited byIModelVisitor.- Returns:
trueif at least one element of this class was removed.
-
elementesWereRemoved
public boolean elementesWereRemoved()Returns whether elements were removed during the last iteration.- Returns:
trueif at least one element was removed,falseotherwise.
-
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
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,falseit is unclear.
-
markForImportRemoval
Marks an element of an imported project for removal if the relatedProjectImportwas deleted.- Parameters:
declaringProject- The project were the element was created.nestedElement- The element itself.
-
removeElementsOfRemovedImports
void removeElementsOfRemovedImports()Removes elements of removedProjectImport, must be called after theProjectRewriteVisitoris finished with a complete visitation iteration and beforeclear(). -
getInstancesForType
Returns the set of instances of the givenIDatatype.- Parameters:
config- The configuration which is used to retrieve allIDecisionVariables.type- The exactIDatatypefor which the instances shall be returned, will not considerIDatatype.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 givenAbstractVariabledeclaration.- Parameters:
config- The configuration which is used to retrieve allIDecisionVariables.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 multipleIDecisionVariables.- Returns:
- The instances for the given declaration or null if no instances exist.
-
declarationKnown
Checks whether the declaration is known or whether the declaration is a local declaration used as an iterator of a constraint. Needs that the internalVariableLookUpTablewas already initialized with aConfiguration.- Parameters:
declaration- The declaration to check.- Returns:
trueif the declaration is used for aIDecisionVariableof the configuration or if the internal table was not initialized with aConfiguration,falseotherwise.
-
addUsedProject
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:
-