Class AssignmentDetector
- java.lang.Object
-
- de.uni_hildesheim.sse.translation.AssignmentDetector
-
- All Implemented Interfaces:
IConstraintTreeVisitor
public class AssignmentDetector extends java.lang.Object implements IConstraintTreeVisitor
Implements a visitor which searches for assignments. Instances of this class may be reused by callingclear()after use.
-
-
Field Summary
Fields Modifier and Type Field Description private booleanisAssignmentprivate intlevelstatic intLEVEL_UNLIMITEDThe level specification to be used if traversal shall not be limited.private intmaxLevelstatic intNO_DEEP_TRAVERSALThe level specification to be used if no deep traversal shall happen (just the top level).
-
Constructor Summary
Constructors Constructor Description AssignmentDetector()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears this visitor for reuse.private booleancontinueTraversal()Returns whether the traversal of the given constraint shall be continued in case of nested trees.booleanisAssignment()Returns whether the expression is an assignment at maximum at the given level.voidsetMaxLevel(int level)Defines the maximum search level.voidvisitAnnotationVariable(AttributeVariable variable)Visits aAttributeVariable.voidvisitBlockExpression(BlockExpression block)Visits the block.voidvisitComment(Comment comment)Visits a comment.voidvisitCompoundAccess(CompoundAccess access)Visits a compound access node.voidvisitCompoundInitializer(CompoundInitializer initializer)Visits a compound initializer.voidvisitConstantValue(ConstantValue value)Visits a constant value.voidvisitContainerInitializer(ContainerInitializer initializer)Visits a container initializer.voidvisitContainerOperationCall(ContainerOperationCall call)Visits a container operation call (e.g.voidvisitDeferInitExpression(DeferInitExpression expression)Visits a default init expression.voidvisitIfThen(IfThen ifThen)Visits an if-then-else expression.voidvisitLet(Let let)Visits a let expression.voidvisitMultiAndExpression(MultiAndExpression expression)Visits a multi-and expression.voidvisitOclFeatureCall(OCLFeatureCall call)Visits an OCL feature call.voidvisitParenthesis(Parenthesis parenthesis)Visits a parenthesis.voidvisitSelf(Self self)Visits self.voidvisitUnresolvedExpression(UnresolvedExpression expression)Visits an unresolved expression.voidvisitVariable(Variable variable)Visits a variable.
-
-
-
Field Detail
-
LEVEL_UNLIMITED
public static final int LEVEL_UNLIMITED
The level specification to be used if traversal shall not be limited.- See Also:
- Constant Field Values
-
NO_DEEP_TRAVERSAL
public static final int NO_DEEP_TRAVERSAL
The level specification to be used if no deep traversal shall happen (just the top level).- See Also:
- Constant Field Values
-
isAssignment
private boolean isAssignment
-
maxLevel
private int maxLevel
-
level
private int level
-
-
Method Detail
-
setMaxLevel
public void setMaxLevel(int level)
Defines the maximum search level.- Parameters:
level- the maximum search level, may beLEVEL_UNLIMITEDin order to avoid any level limitation orNO_DEEP_TRAVERSALin order to avoid
-
isAssignment
public boolean isAssignment()
Returns whether the expression is an assignment at maximum at the given level.- Returns:
trueif it is an assignment,falseelse
-
clear
public void clear()
Clears this visitor for reuse.
-
visitConstantValue
public void visitConstantValue(ConstantValue value)
Description copied from interface:IConstraintTreeVisitorVisits a constant value.- Specified by:
visitConstantValuein interfaceIConstraintTreeVisitor- Parameters:
value- the value which should be visited
-
visitVariable
public void visitVariable(Variable variable)
Description copied from interface:IConstraintTreeVisitorVisits a variable.- Specified by:
visitVariablein interfaceIConstraintTreeVisitor- Parameters:
variable- the variable which should be visited
-
visitAnnotationVariable
public void visitAnnotationVariable(AttributeVariable variable)
Description copied from interface:IConstraintTreeVisitorVisits aAttributeVariable.- Specified by:
visitAnnotationVariablein interfaceIConstraintTreeVisitor- Parameters:
variable- the attribute variable which should be visited
-
continueTraversal
private boolean continueTraversal()
Returns whether the traversal of the given constraint shall be continued in case of nested trees. Continuation is not needed if already an assignment has been found or the maximum level is exceeded.- Returns:
trueif the traversal shall be continued,falseelse
-
visitParenthesis
public void visitParenthesis(Parenthesis parenthesis)
Description copied from interface:IConstraintTreeVisitorVisits a parenthesis.- Specified by:
visitParenthesisin interfaceIConstraintTreeVisitor- Parameters:
parenthesis- the parenthesis which should be visited
-
visitComment
public void visitComment(Comment comment)
Description copied from interface:IConstraintTreeVisitorVisits a comment.- Specified by:
visitCommentin interfaceIConstraintTreeVisitor- Parameters:
comment- the comment node which should be visited
-
visitOclFeatureCall
public void visitOclFeatureCall(OCLFeatureCall call)
Description copied from interface:IConstraintTreeVisitorVisits an OCL feature call.- Specified by:
visitOclFeatureCallin interfaceIConstraintTreeVisitor- Parameters:
call- the feature call which should be visited
-
visitDeferInitExpression
public void visitDeferInitExpression(DeferInitExpression expression)
Description copied from interface:IConstraintTreeVisitorVisits a default init expression.- Specified by:
visitDeferInitExpressionin interfaceIConstraintTreeVisitor- Parameters:
expression- the expression
-
visitMultiAndExpression
public void visitMultiAndExpression(MultiAndExpression expression)
Description copied from interface:IConstraintTreeVisitorVisits a multi-and expression.- Specified by:
visitMultiAndExpressionin interfaceIConstraintTreeVisitor- Parameters:
expression- the expression to be visited
-
visitLet
public void visitLet(Let let)
Description copied from interface:IConstraintTreeVisitorVisits a let expression.- Specified by:
visitLetin interfaceIConstraintTreeVisitor- Parameters:
let- the let expression which should be visited
-
visitIfThen
public void visitIfThen(IfThen ifThen)
Description copied from interface:IConstraintTreeVisitorVisits an if-then-else expression.- Specified by:
visitIfThenin interfaceIConstraintTreeVisitor- Parameters:
ifThen- the if-then-else expression which should be visited
-
visitContainerOperationCall
public void visitContainerOperationCall(ContainerOperationCall call)
Description copied from interface:IConstraintTreeVisitorVisits a container operation call (e.g. quantors, iterators).- Specified by:
visitContainerOperationCallin interfaceIConstraintTreeVisitor- Parameters:
call- the container operation call
-
visitCompoundAccess
public void visitCompoundAccess(CompoundAccess access)
Description copied from interface:IConstraintTreeVisitorVisits a compound access node.- Specified by:
visitCompoundAccessin interfaceIConstraintTreeVisitor- Parameters:
access- the compound access node
-
visitUnresolvedExpression
public void visitUnresolvedExpression(UnresolvedExpression expression)
Description copied from interface:IConstraintTreeVisitorVisits an unresolved expression. Please note that an unresolved expression may represent a leaf as well as an inner tree node. Typically, visitors shall continue visiting transparently atUnresolvedExpression.getActualExpression().- Specified by:
visitUnresolvedExpressionin interfaceIConstraintTreeVisitor- Parameters:
expression- the expression
-
visitCompoundInitializer
public void visitCompoundInitializer(CompoundInitializer initializer)
Description copied from interface:IConstraintTreeVisitorVisits a compound initializer.- Specified by:
visitCompoundInitializerin interfaceIConstraintTreeVisitor- Parameters:
initializer- the compound initializer node
-
visitContainerInitializer
public void visitContainerInitializer(ContainerInitializer initializer)
Description copied from interface:IConstraintTreeVisitorVisits a container initializer.- Specified by:
visitContainerInitializerin interfaceIConstraintTreeVisitor- Parameters:
initializer- the container initializer node
-
visitSelf
public void visitSelf(Self self)
Description copied from interface:IConstraintTreeVisitorVisits self.- Specified by:
visitSelfin interfaceIConstraintTreeVisitor- Parameters:
self- the self object to visit
-
visitBlockExpression
public void visitBlockExpression(BlockExpression block)
Description copied from interface:IConstraintTreeVisitorVisits the block.- Specified by:
visitBlockExpressionin interfaceIConstraintTreeVisitor- Parameters:
block- the block to be visited
-
-