blob: ea8643314b83abb715b65af37d022e6dd0ee77a7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
package rba.tool.editor.validation.validators
import org.eclipse.xtext.validation.Check
import org.eclipse.xtext.validation.EValidatorRegistrar
import rba.core.ExistsOperator
import rba.core.Expression
import rba.core.ExpressionType
import rba.core.RBACorePackage
import rba.core.SetOfOperator
import rba.tool.editor.messages.Messages
import rba.tool.editor.validation.AbstractRBAModelValidator
class ExistsOperatorValidator extends AbstractRBAModelValidator {
private String EXISTS_OPERAND_SIZE = Messages.EXISTS_OPERAND_SIZE;
private String EXISTS_OPERAND_TYPE = Messages.EXISTS_OPERAND_TYPE;
override register(EValidatorRegistrar registrar) {
// not needed for classes used as ComposedCheck
}
@Check(NORMAL)
def checkExistsOperator(ExistsOperator existsOperator) {
if (existsOperator.operand.size > 1) {
error(EXISTS_OPERAND_SIZE, RBACorePackage.Literals.OPERATOR__OPERAND)
return;
}
var operand = existsOperator.operand.get(0)
if (operand.type != ExpressionType.SET_OF_CONTENT && operand.type != ExpressionType.SET_OF_AREA &&
operand.type != ExpressionType.SET_OF_ZONE && operand.type != ExpressionType.SET_OF_SOUND &&
isInvalidSetOfOperator(operand)) {
error(EXISTS_OPERAND_TYPE, RBACorePackage.Literals.OPERATOR__OPERAND)
return;
}
}
// check whether operator is SetOfOperator and operand type is not type of Area,Content,Zone,Sound or Animation
def isInvalidSetOfOperator(Expression operand) {
if (operand instanceof SetOfOperator) {
if (operand.type == ExpressionType.AREA || operand.type == ExpressionType.CONTENT ||
operand.type == ExpressionType.ZONE || operand.type == ExpressionType.SOUND) {
return false
}
}
return true
}
}
|