Class IvmlValidationVisitor
java.lang.Object
net.ssehub.easy.varModel.model.AbstractVisitor
net.ssehub.easy.varModel.validation.IvmlValidationVisitor
- All Implemented Interfaces:
IConstraintTreeVisitor,ICustomDatatypeVisitor,IModelVisitor,IValueVisitor
public class IvmlValidationVisitor
extends AbstractVisitor
implements IValueVisitor, IConstraintTreeVisitor
Checks a model for IVML compliance. This visitor is currently not complete!
- Author:
- Holger Eichelberger, El-Sharkawy
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddElementIsNullError(String elementName, int pos, Object cause) Adds an error because the given element is null.private voidAdds an error and appends the current location if possible.private voidcheckComment(String text, boolean allowNull, Object cause) Checks a comment.private voidprivate booleancheckExpression(ConstraintSyntaxTree expression, String info, Object cause) Checks for a valid (sub-)expression.private voidcheckIdentifier(String identifier, String info, Object cause, boolean allowWildcard) Checks for a valid identifier and stores an error message if required.private voidcheckNameIdentifier(String identifier, Object cause) Checks for a valid (name) identifier and stores an error message if required.private voidcheckParent(IModelElement parent, Object cause, IModelElement expectedParent) Checks for a valid parent (reference).private voidcheckParent(IModelElement element, IModelElement expectedParent) Checks for a valid parent (reference).private voidChecks for a valid datatype.intReturns the number of detected errors.getMessage(int index) Returns the specified message.intReturns the number of detected messages.voidvisitAnnotationVariable(AttributeVariable variable) Visits aAttributeVariable.voidvisitAttribute(Attribute attribute) Method for visiting an attribute.voidvisitAttributeAssignment(AttributeAssignment assignment) Visits an attribute assignment.voidVisits the block.voidvisitBooleanValue(BooleanValue value) This method is used for visiting BooleanValue.voidvisitComment(Comment comment) Visits a comment.voidvisitComment(Comment comment) Method for visiting a comment.voidvisitCompound(Compound compound) Method for visiting a compound.voidvisitCompoundAccess(CompoundAccess access) Visits a compound access node.voidVisits a compound access statement (may occur in freeze blocks.voidvisitCompoundInitializer(CompoundInitializer initializer) Visits a compound initializer.voidvisitCompoundValue(CompoundValue value) This method is used for visiting CompoundValue.voidvisitConstantValue(ConstantValue value) Visits a constant value.voidvisitConstraint(Constraint constraint) Method for visiting a constraint.voidThis method is used for visiting ConstraintValue.voidvisitContainerInitializer(ContainerInitializer initializer) Visits a container initializer.voidVisits a container operation call (e.g.voidThis method is used for visiting ContainerValue.voidThis method is used for visiting a decision variable declaration.voidvisitDeferInitExpression(DeferInitExpression expression) Visits a default init expression.voidvisitDerivedDatatype(DerivedDatatype datatype) Method for visiting a derived datatype.voidMethod for visiting an enum.voidvisitEnumLiteral(EnumLiteral literal) Method for visiting an enum literal.voidvisitEnumValue(EnumValue value) This method is used for visiting EnumValue.voidvisitFreezeBlock(FreezeBlock freeze) Method for visiting a freeze block.voidvisitIfThen(IfThen ifThen) Visits an if-then-else expression.voidvisitIntValue(IntValue value) This method is used for visiting IntValue.voidVisits a let expression.voidvisitMetaTypeValue(MetaTypeValue value) This method is used for visiting meta type value.voidvisitMultiAndExpression(MultiAndExpression expression) Visits a multi-and expression.voidvisitNullValue(NullValue value) This method is used for visiting a null value.voidVisits an OCL feature call.voidMethod for visiting an operation definition.voidvisitOrderedEnum(OrderedEnum eenum) Method for visiting an ordered enum.voidvisitParenthesis(Parenthesis parenthesis) Visits a parenthesis.voidMethod for visiting a partial evaluation block.voidvisitProject(Project project) Method for visiting a project.voidvisitProjectImport(ProjectImport pImport) This method is used for visiting a ProjectImport.voidMethod for visiting a project interface.voidvisitRealValue(RealValue value) This method is used for visiting RealValue.voidvisitReference(Reference reference) Method for visiting a reference.voidvisitReferenceValue(ReferenceValue referenceValue) This method is used for visiting referenceValue.voidVisits self.voidvisitSequence(Sequence sequence) Method for visiting a sequence.voidMethod for visiting a set.voidvisitStringValue(StringValue value) This method is used for visiting StringValue.voidvisitUnresolvedExpression(UnresolvedExpression expression) Visits an unresolved expression.voidvisitVariable(Variable variable) Visits a variable.voidvisitVersionValue(VersionValue value) This method is used for visiting a version value.
-
Field Details
-
messages
-
location
-
customTypes
-
-
Constructor Details
-
IvmlValidationVisitor
public IvmlValidationVisitor()
-
-
Method Details
-
getErrorCount
public int getErrorCount()Returns the number of detected errors.- Returns:
- the number of detected errors
-
getMessageCount
public int getMessageCount()Returns the number of detected messages.- Returns:
- the number of detected messages
-
getMessage
Returns the specified message.- Parameters:
index- the index of the message to return- Returns:
- the message
- Throws:
IndexOutOfBoundsException- ifindex < 0 || index >=getMessageCount()}
-
checkDeclaration
- Parameters:
decl- The declaration to check, must be part of the project.
-
checkNameIdentifier
Checks for a valid (name) identifier and stores an error message if required.- Parameters:
identifier- the identifier to check forcause- the cause for the error (may be null)
-
checkIdentifier
Checks for a valid identifier and stores an error message if required.- Parameters:
identifier- the identifier to check forinfo- optional information denoting the specific part with invalid identifiercause- the cause for the error (may be null)allowWildcard- allows for wildcard characters
-
checkType
Checks for a valid datatype.- Parameters:
type- the type to be checkedcause- the cause for the error (may be null)
-
checkParent
Checks for a valid parent (reference).- Parameters:
element- the element to check the parent reference forexpectedParent- the expected parent reference
-
checkParent
Checks for a valid parent (reference).- Parameters:
parent- the parent reference forcause- the cause for the error (the holder of the parent reference)expectedParent- the expected parent reference
-
checkComment
Checks a comment.- Parameters:
text- the comment textallowNull- iftruethentext==nullis not considered as an error, iffalsean error is registered in case oftext==nullcause- the cause for the error (may be null)
-
checkExpression
Checks for a valid (sub-)expression.- Parameters:
expression- the expression to checkinfo- optional information denoting the specific expressioncause- the cause for the error (may be null)- Returns:
trueif the expression is valid,falseelse
-
addError
Adds an error and appends the current location if possible.- Parameters:
text- the textual description of the errorcause- the cause for the error (may be null)code- specifies the kind of the error (ValidationMessage)
-
addElementIsNullError
Adds an error because the given element is null.- Parameters:
elementName- the logical name of the elementpos- the position within the element collectioncause- the cause for the error (may be null)
-
visitProject
Description copied from interface:IModelVisitorMethod for visiting a project.- Specified by:
visitProjectin interfaceIModelVisitor- Overrides:
visitProjectin classAbstractVisitor- Parameters:
project- The project which should be visited.
-
visitEnum
Description copied from interface:ICustomDatatypeVisitorMethod for visiting an enum.- Specified by:
visitEnumin interfaceICustomDatatypeVisitor- Overrides:
visitEnumin classAbstractVisitor- Parameters:
eenum- The enum which should be visited.
-
visitOrderedEnum
Description copied from interface:ICustomDatatypeVisitorMethod for visiting an ordered enum.- Specified by:
visitOrderedEnumin interfaceICustomDatatypeVisitor- Overrides:
visitOrderedEnumin classAbstractVisitor- Parameters:
eenum- The enum which should be visited.
-
visitCompound
Description copied from interface:ICustomDatatypeVisitorMethod for visiting a compound.- Specified by:
visitCompoundin interfaceICustomDatatypeVisitor- Overrides:
visitCompoundin classAbstractVisitor- Parameters:
compound- The compound which should be visited.
-
visitProjectImport
Description copied from interface:IModelVisitorThis method is used for visiting a ProjectImport.- Specified by:
visitProjectImportin interfaceIModelVisitor- Parameters:
pImport- One ProjectImport which should be visited.
-
visitDecisionVariableDeclaration
Description copied from interface:IModelVisitorThis method is used for visiting a decision variable declaration.- Specified by:
visitDecisionVariableDeclarationin interfaceIModelVisitor- Parameters:
decl- One declaration which should be visited.
-
visitAttribute
Description copied from interface:IModelVisitorMethod for visiting an attribute.- Specified by:
visitAttributein interfaceIModelVisitor- Parameters:
attribute- The attribute which should be visited.
-
visitConstraint
Description copied from interface:IModelVisitorMethod for visiting a constraint.- Specified by:
visitConstraintin interfaceIModelVisitor- Parameters:
constraint- The constraint which should be visited.
-
visitFreezeBlock
Description copied from interface:IModelVisitorMethod for visiting a freeze block.- Specified by:
visitFreezeBlockin interfaceIModelVisitor- Parameters:
freeze- The freeze block which should be visited.
-
visitOperationDefinition
Description copied from interface:IModelVisitorMethod for visiting an operation definition.- Specified by:
visitOperationDefinitionin interfaceIModelVisitor- Parameters:
opdef- The operation definition which should be visited.
-
visitPartialEvaluationBlock
Description copied from interface:IModelVisitorMethod for visiting a partial evaluation block.- Specified by:
visitPartialEvaluationBlockin interfaceIModelVisitor- Parameters:
block- The partial evaluation block which should be visited.
-
visitProjectInterface
Description copied from interface:IModelVisitorMethod for visiting a project interface.- Specified by:
visitProjectInterfacein interfaceIModelVisitor- Parameters:
iface- The interface which should be visited.
-
visitComment
Description copied from interface:IModelVisitorMethod for visiting a comment.- Specified by:
visitCommentin interfaceIModelVisitor- Parameters:
comment- the comment to visit
-
visitAttributeAssignment
Description copied from interface:IModelVisitorVisits an attribute assignment.- Specified by:
visitAttributeAssignmentin interfaceIModelVisitor- Parameters:
assignment- the assignment to visit
-
visitDerivedDatatype
Description copied from interface:ICustomDatatypeVisitorMethod for visiting a derived datatype.- Specified by:
visitDerivedDatatypein interfaceICustomDatatypeVisitor- Parameters:
datatype- The datatype which should be visited.
-
visitEnumLiteral
Description copied from interface:ICustomDatatypeVisitorMethod for visiting an enum literal.- Specified by:
visitEnumLiteralin interfaceICustomDatatypeVisitor- Parameters:
literal- The literal which should be visited.
-
visitReference
Description copied from interface:ICustomDatatypeVisitorMethod for visiting a reference.- Specified by:
visitReferencein interfaceICustomDatatypeVisitor- Parameters:
reference- The reference which should be visited.
-
visitSequence
Description copied from interface:ICustomDatatypeVisitorMethod for visiting a sequence.- Specified by:
visitSequencein interfaceICustomDatatypeVisitor- Parameters:
sequence- The sequence which should be visited.
-
visitSet
Description copied from interface:ICustomDatatypeVisitorMethod for visiting a set.- Specified by:
visitSetin interfaceICustomDatatypeVisitor- Parameters:
set- The set which should be visited.
-
visitConstantValue
Description copied from interface:IConstraintTreeVisitorVisits a constant value.- Specified by:
visitConstantValuein interfaceIConstraintTreeVisitor- Parameters:
value- the value which should be visited
-
visitVariable
Description copied from interface:IConstraintTreeVisitorVisits a variable.- Specified by:
visitVariablein interfaceIConstraintTreeVisitor- Parameters:
variable- the variable which should be visited
-
visitParenthesis
Description copied from interface:IConstraintTreeVisitorVisits a parenthesis.- Specified by:
visitParenthesisin interfaceIConstraintTreeVisitor- Parameters:
parenthesis- the parenthesis which should be visited
-
visitComment
Description copied from interface:IConstraintTreeVisitorVisits a comment.- Specified by:
visitCommentin interfaceIConstraintTreeVisitor- Parameters:
comment- the comment node which should be visited
-
visitOclFeatureCall
Description copied from interface:IConstraintTreeVisitorVisits an OCL feature call.- Specified by:
visitOclFeatureCallin interfaceIConstraintTreeVisitor- Parameters:
call- the feature call which should be visited
-
visitDeferInitExpression
Description copied from interface:IConstraintTreeVisitorVisits a default init expression.- Specified by:
visitDeferInitExpressionin interfaceIConstraintTreeVisitor- Parameters:
expression- the expression
-
visitMultiAndExpression
Description copied from interface:IConstraintTreeVisitorVisits a multi-and expression.- Specified by:
visitMultiAndExpressionin interfaceIConstraintTreeVisitor- Parameters:
expression- the expression to be visited
-
visitLet
Description copied from interface:IConstraintTreeVisitorVisits a let expression.- Specified by:
visitLetin interfaceIConstraintTreeVisitor- Parameters:
let- the let expression which should be visited
-
visitIfThen
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
Description copied from interface:IConstraintTreeVisitorVisits a container operation call (e.g. quantors, iterators).- Specified by:
visitContainerOperationCallin interfaceIConstraintTreeVisitor- Parameters:
call- the container operation call
-
visitCompoundAccess
Description copied from interface:IConstraintTreeVisitorVisits a compound access node.- Specified by:
visitCompoundAccessin interfaceIConstraintTreeVisitor- Parameters:
access- the compound access node
-
visitUnresolvedExpression
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
Description copied from interface:IConstraintTreeVisitorVisits a compound initializer.- Specified by:
visitCompoundInitializerin interfaceIConstraintTreeVisitor- Parameters:
initializer- the compound initializer node
-
visitContainerInitializer
Description copied from interface:IConstraintTreeVisitorVisits a container initializer.- Specified by:
visitContainerInitializerin interfaceIConstraintTreeVisitor- Parameters:
initializer- the container initializer node
-
visitConstraintValue
Description copied from interface:IValueVisitorThis method is used for visiting ConstraintValue.- Specified by:
visitConstraintValuein interfaceIValueVisitor- Parameters:
value- One ConstraintValue which should be visited.
-
visitEnumValue
Description copied from interface:IValueVisitorThis method is used for visiting EnumValue.- Specified by:
visitEnumValuein interfaceIValueVisitor- Parameters:
value- One EnumValue which should be visited.
-
visitStringValue
Description copied from interface:IValueVisitorThis method is used for visiting StringValue.- Specified by:
visitStringValuein interfaceIValueVisitor- Parameters:
value- One StringValue which should be visited.
-
visitCompoundValue
Description copied from interface:IValueVisitorThis method is used for visiting CompoundValue.- Specified by:
visitCompoundValuein interfaceIValueVisitor- Parameters:
value- One CompoundValue which should be visited.
-
visitContainerValue
Description copied from interface:IValueVisitorThis method is used for visiting ContainerValue.- Specified by:
visitContainerValuein interfaceIValueVisitor- Parameters:
value- One CompoundValue which should be visited.
-
visitIntValue
Description copied from interface:IValueVisitorThis method is used for visiting IntValue.- Specified by:
visitIntValuein interfaceIValueVisitor- Parameters:
value- One IntValue which should be visited.
-
visitRealValue
Description copied from interface:IValueVisitorThis method is used for visiting RealValue.- Specified by:
visitRealValuein interfaceIValueVisitor- Parameters:
value- One RealValue which should be visited.
-
visitBooleanValue
Description copied from interface:IValueVisitorThis method is used for visiting BooleanValue.- Specified by:
visitBooleanValuein interfaceIValueVisitor- Parameters:
value- One BooleanValue which should be visited.
-
visitReferenceValue
Description copied from interface:IValueVisitorThis method is used for visiting referenceValue.- Specified by:
visitReferenceValuein interfaceIValueVisitor- Parameters:
referenceValue- One referenceValue which should be visited.
-
visitMetaTypeValue
Description copied from interface:IValueVisitorThis method is used for visiting meta type value.- Specified by:
visitMetaTypeValuein interfaceIValueVisitor- Parameters:
value- a value which should be visited.
-
visitNullValue
Description copied from interface:IValueVisitorThis method is used for visiting a null value.- Specified by:
visitNullValuein interfaceIValueVisitor- Parameters:
value- a value which should be visited (actuallyNullValue.INSTANCE).
-
visitCompoundAccessStatement
Description copied from interface:IModelVisitorVisits a compound access statement (may occur in freeze blocks.- Specified by:
visitCompoundAccessStatementin interfaceIModelVisitor- Parameters:
access- the access statement
-
visitVersionValue
Description copied from interface:IValueVisitorThis method is used for visiting a version value.- Specified by:
visitVersionValuein interfaceIValueVisitor- Parameters:
value- a value which should be visited.
-
visitSelf
Description copied from interface:IConstraintTreeVisitorVisits self.- Specified by:
visitSelfin interfaceIConstraintTreeVisitor- Parameters:
self- the self object to visit
-
visitAnnotationVariable
Description copied from interface:IConstraintTreeVisitorVisits aAttributeVariable.- Specified by:
visitAnnotationVariablein interfaceIConstraintTreeVisitor- Parameters:
variable- the attribute variable which should be visited
-
visitBlockExpression
Description copied from interface:IConstraintTreeVisitorVisits the block.- Specified by:
visitBlockExpressionin interfaceIConstraintTreeVisitor- Parameters:
block- the block to be visited
-