diff options
author | 2021-08-03 18:42:39 +0900 | |
---|---|---|
committer | 2021-08-06 19:32:38 +0900 | |
commit | be4f78978faba3d3ceb88df02a7f93a2e09ff1e0 (patch) | |
tree | 1f3f1a96251ac4f655c8a96fc33d5d4ee779cd06 /rba.tool.editor/src/rba/tool/editor/validation/validators/HasComeEarlierThanValidator.xtend | |
parent | 71ca7c6cab863767ef30c8bd05b2bbfda8731cb5 (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/HasComeEarlierThanValidator.xtend')
-rw-r--r-- | rba.tool.editor/src/rba/tool/editor/validation/validators/HasComeEarlierThanValidator.xtend | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/rba.tool.editor/src/rba/tool/editor/validation/validators/HasComeEarlierThanValidator.xtend b/rba.tool.editor/src/rba/tool/editor/validation/validators/HasComeEarlierThanValidator.xtend new file mode 100644 index 0000000..16a8c34 --- /dev/null +++ b/rba.tool.editor/src/rba/tool/editor/validation/validators/HasComeEarlierThanValidator.xtend @@ -0,0 +1,51 @@ +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.HasComeEarlierThan +import rba.core.PreviousModifier +import rba.core.RBACorePackage +import rba.tool.editor.messages.Messages +import rba.tool.editor.validation.AbstractRBAModelValidator + +class HasComeEarlierThanValidator extends AbstractRBAModelValidator { + + private static final String TargetOperatorName = HasComeEarlierThan.simpleName + + override register(EValidatorRegistrar registrar) { + // not needed for classes used as ComposedCheck + } + + @Check(NORMAL) + def checkContentValue(HasComeEarlierThan hasComeEarlierThan) { + if (hasComeEarlierThan.operand.size < 2) { + error(String.format(Messages.OPERAND_SIZE_TWO, TargetOperatorName), + RBACorePackage.Literals.OPERATOR__OPERAND) + return; + } + var firstOperand = hasComeEarlierThan.operand.get(0) + if (firstOperand.type != ExpressionType::CONTENT && firstOperand.type != ExpressionType::SOUND) { + error(String.format(Messages.FIRST_OPERAND_MUST_CONTENT, TargetOperatorName), + RBACorePackage.Literals.OPERATOR__OPERAND) + return; + } + var argument = hasComeEarlierThan.operand.get(1) + if (argument.type != ExpressionType::CONTENT && argument.type != ExpressionType::SOUND) { + error(String.format(Messages.ARGUMENT_MUST_CONTENT, TargetOperatorName), + RBACorePackage.Literals.OPERATOR__OPERAND, 1) + return; + } + if (firstOperand instanceof PreviousModifier) { + error(String.format(Messages.OPERAND_CANNOT_USE_PRE, TargetOperatorName), + RBACorePackage.Literals.OPERATOR__OPERAND) + return; + } + if (argument instanceof PreviousModifier) { + error(String.format(Messages.ARGUMENT_CANNOT_USE_PRE, TargetOperatorName), + RBACorePackage.Literals.OPERATOR__OPERAND, 1) + return; + } + + } +} |