aboutsummaryrefslogtreecommitdiffstats
path: root/rba.tool.editor/src/rba/tool/editor/validation/validators/ExistsOperatorValidator.xtend
diff options
context:
space:
mode:
authorKenji Hosokawa <khosokawa@jp.adit-jv.com>2021-08-03 18:42:39 +0900
committerKenji Hosokawa <khosokawa@jp.adit-jv.com>2021-08-06 19:32:38 +0900
commitbe4f78978faba3d3ceb88df02a7f93a2e09ff1e0 (patch)
tree1f3f1a96251ac4f655c8a96fc33d5d4ee779cd06 /rba.tool.editor/src/rba/tool/editor/validation/validators/ExistsOperatorValidator.xtend
parent71ca7c6cab863767ef30c8bd05b2bbfda8731cb5 (diff)
Initial commit
Bug-AGL: SPEC-4033 Signed-off-by: Kenji Hosokawa <khosokawa@jp.adit-jv.com>
Diffstat (limited to 'rba.tool.editor/src/rba/tool/editor/validation/validators/ExistsOperatorValidator.xtend')
-rw-r--r--rba.tool.editor/src/rba/tool/editor/validation/validators/ExistsOperatorValidator.xtend48
1 files changed, 48 insertions, 0 deletions
diff --git a/rba.tool.editor/src/rba/tool/editor/validation/validators/ExistsOperatorValidator.xtend b/rba.tool.editor/src/rba/tool/editor/validation/validators/ExistsOperatorValidator.xtend
new file mode 100644
index 0000000..ea86433
--- /dev/null
+++ b/rba.tool.editor/src/rba/tool/editor/validation/validators/ExistsOperatorValidator.xtend
@@ -0,0 +1,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
+ }
+}