aboutsummaryrefslogtreecommitdiffstats
path: root/rba.tool.editor/src/rba/tool/editor/validation/validators/GetAllocatablesValidator.xtend
blob: a31f2f8ee2e3173a665d358b32bc569e41e14dd1 (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
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;
			}
		}
	}
}