summaryrefslogtreecommitdiffstats
path: root/rba.tool.editor/src/rba/tool/editor/validation/validators/GetAllocatablesValidator.xtend
diff options
context:
space:
mode:
Diffstat (limited to 'rba.tool.editor/src/rba/tool/editor/validation/validators/GetAllocatablesValidator.xtend')
-rw-r--r--rba.tool.editor/src/rba/tool/editor/validation/validators/GetAllocatablesValidator.xtend34
1 files changed, 34 insertions, 0 deletions
diff --git a/rba.tool.editor/src/rba/tool/editor/validation/validators/GetAllocatablesValidator.xtend b/rba.tool.editor/src/rba/tool/editor/validation/validators/GetAllocatablesValidator.xtend
new file mode 100644
index 0000000..a31f2f8
--- /dev/null
+++ b/rba.tool.editor/src/rba/tool/editor/validation/validators/GetAllocatablesValidator.xtend
@@ -0,0 +1,34 @@
+package rba.tool.editor.validation.validators
+
+import org.eclipse.xtext.validation.Check
+import org.eclipse.xtext.validation.EValidatorRegistrar
+import rba.core.ExpressionType
+import rba.core.GetAllocatables
+import rba.core.RBACorePackage
+import rba.tool.editor.messages.Messages
+import rba.tool.editor.validation.AbstractRBAModelValidator
+
+class GetAllocatablesValidator extends AbstractRBAModelValidator {
+
+ private String GETALLOCATABLES_SIZE = Messages.GETALLOCATABLES_SIZE;
+
+ private String GETALLOCATABLES_TYPE = Messages.GETALLOCATABLES_TYPE;
+
+ override register(EValidatorRegistrar registrar) {
+ // not needed for classes used as ComposedCheck
+ }
+
+ @Check(NORMAL)
+ def checkGetAllocatable(GetAllocatables getAllocatable) {
+ if (getAllocatable.operand.size > 1) {
+ error(GETALLOCATABLES_SIZE, RBACorePackage.Literals.OPERATOR__OPERAND)
+ return;
+ }
+ for (operand : getAllocatable.operand) {
+ if (operand.type != ExpressionType.CONTENT && operand.type != ExpressionType.SOUND) {
+ error(GETALLOCATABLES_TYPE, RBACorePackage.Literals.OPERATOR__OPERAND)
+ return;
+ }
+ }
+ }
+}