Class DeclarationFinder
- java.lang.Object
-
- net.ssehub.easy.varModel.model.AbstractProjectVisitor
-
- net.ssehub.easy.varModel.model.filter.AbstractDeclarationFinder
-
- net.ssehub.easy.varModel.model.filter.DeclarationFinder
-
- All Implemented Interfaces:
ICustomDatatypeVisitor,IModelVisitor
public class DeclarationFinder extends AbstractDeclarationFinder
This class locates all top-level DecisionVariableDeclaration in a project.- Author:
- beck, El-Sharkawy
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDeclarationFinder.VisibilityTypeSpecifies which kind of found declarations shall by returned.
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<AbstractVariable>allDeclarationsprivate java.util.List<AbstractVariable>hiddenDeclarationsprivate java.util.Stack<java.util.Set<AbstractVariable>>interfacesprivate booleanonlyToplevelprivate IDatatypetypeprivate java.util.List<AbstractVariable>visibleDeclarations
-
Constructor Summary
Constructors Constructor Description DeclarationFinder(Project project, FilterType filterType, IDatatype type)Constructor for specifying whether search results should be filtered regarding the specifiedIDatatype.DeclarationFinder(Project project, FilterType filterType, IDatatype type, boolean onlyToplevel)Constructor for specifying whether search results should be filtered regarding the specifiedIDatatypeand whether only toplevel variables should be retrieved.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddDeclaration(AbstractVariable decl)Adds a visitedAbstractVariableto the correct list of found declarations, depending on whether the variable is visible (no interface or exported by an interface) or is hidden.java.util.List<AbstractVariable>getVariableDeclarations(DeclarationFinder.VisibilityType type)Getter for returning all DecisionVariableDeclarations of a Project.private booleanisVisible(AbstractVariable decl)Checks whether a given variables is hidden by an interface or visible.voidvisitAttributeAssignment(AttributeAssignment assignment)Visits an attribute assignment.voidvisitCompound(Compound compound)Method for visiting a compound.voidvisitCompoundAccessStatement(CompoundAccessStatement access)Visits a compound access statement (may occur in freeze blocks.voidvisitDecisionVariableDeclaration(DecisionVariableDeclaration decl)This method is used for visiting a decision variable declaration.voidvisitProjectImport(ProjectImport pImport)This method is used for visiting a ProjectImport.-
Methods inherited from class net.ssehub.easy.varModel.model.filter.AbstractDeclarationFinder
visitAttribute, visitComment, visitConstraint, visitDerivedDatatype, visitEnum, visitEnumLiteral, visitFreezeBlock, visitOperationDefinition, visitOrderedEnum, visitPartialEvaluationBlock, visitProjectInterface, visitReference, visitSequence, visitSet
-
Methods inherited from class net.ssehub.easy.varModel.model.AbstractProjectVisitor
clear, getFilterType, getStartingProject, visitProject
-
-
-
-
Field Detail
-
visibleDeclarations
private java.util.List<AbstractVariable> visibleDeclarations
-
hiddenDeclarations
private java.util.List<AbstractVariable> hiddenDeclarations
-
allDeclarations
private java.util.List<AbstractVariable> allDeclarations
-
type
private IDatatype type
-
interfaces
private java.util.Stack<java.util.Set<AbstractVariable>> interfaces
-
onlyToplevel
private boolean onlyToplevel
-
-
Constructor Detail
-
DeclarationFinder
public DeclarationFinder(Project project, FilterType filterType, IDatatype type)
Constructor for specifying whether search results should be filtered regarding the specifiedIDatatype. Will only find toplevel declarations.- Parameters:
project- The project where all DecisionVariableDeclarations should be found.filterType- Specifies whether project imports shall be considered or not.type- If type is not null only declarations matching the specified type will be found
-
DeclarationFinder
public DeclarationFinder(Project project, FilterType filterType, IDatatype type, boolean onlyToplevel)
Constructor for specifying whether search results should be filtered regarding the specifiedIDatatypeand whether only toplevel variables should be retrieved.- Parameters:
project- The project where all DecisionVariableDeclarations should be found.filterType- Specifies whether project imports shall be considered or not.type- If type is not null only declarations matching the specified type will be foundonlyToplevel- true only toplevel declarations will be found, false will also consider declarations inside compounds.
-
-
Method Detail
-
getVariableDeclarations
public java.util.List<AbstractVariable> getVariableDeclarations(DeclarationFinder.VisibilityType type)
Getter for returning all DecisionVariableDeclarations of a Project.- Parameters:
type- Specification whether only exported, not exported, or all declarations shall be returned:DeclarationFinder.VisibilityType.ONLY_EXPORTED: All variables which are not hidden by an interface will be returned.DeclarationFinder.VisibilityType.ONLY_HIDDEN: All variables which are hidden by an interface will be returned.DeclarationFinder.VisibilityType.ALL: All variables be returned.
- Returns:
- A List with all top-level DecisionVariableDeclarations
-
visitProjectImport
public void visitProjectImport(ProjectImport pImport)
Description copied from interface:IModelVisitorThis method is used for visiting a ProjectImport.- Specified by:
visitProjectImportin interfaceIModelVisitor- Overrides:
visitProjectImportin classAbstractProjectVisitor- Parameters:
pImport- One ProjectImport which should be visited.
-
visitDecisionVariableDeclaration
public void visitDecisionVariableDeclaration(DecisionVariableDeclaration decl)
Description copied from interface:IModelVisitorThis method is used for visiting a decision variable declaration.- Parameters:
decl- One declaration which should be visited.
-
visitAttributeAssignment
public void visitAttributeAssignment(AttributeAssignment assignment)
Description copied from interface:IModelVisitorVisits an attribute assignment.- Parameters:
assignment- the assignment to visit
-
isVisible
private boolean isVisible(AbstractVariable decl)
Checks whether a given variables is hidden by an interface or visible.- Parameters:
decl- TheAbstractVariableto check.- Returns:
- false if the variable is hidden by an interface, true otherwise
-
addDeclaration
private void addDeclaration(AbstractVariable decl)
Adds a visitedAbstractVariableto the correct list of found declarations, depending on whether the variable is visible (no interface or exported by an interface) or is hidden.- Parameters:
decl- AAbstractVariablewhich shall be added to the list found declarations (getVariableDeclarations(VisibilityType).- See Also:
isVisible(AbstractVariable)
-
visitCompoundAccessStatement
public void visitCompoundAccessStatement(CompoundAccessStatement access)
Description copied from interface:IModelVisitorVisits a compound access statement (may occur in freeze blocks.- Parameters:
access- the access statement
-
visitCompound
public void visitCompound(Compound compound)
Description copied from interface:ICustomDatatypeVisitorMethod for visiting a compound.- Specified by:
visitCompoundin interfaceICustomDatatypeVisitor- Overrides:
visitCompoundin classAbstractDeclarationFinder- Parameters:
compound- The compound which should be visited.
-
-