diff options
author | 2024-05-17 18:52:39 +0200 | |
---|---|---|
committer | 2024-05-26 17:22:32 +0200 | |
commit | 9fba55097010c5c57af35d9752517bad2a6d32a6 (patch) | |
tree | 88a1667f715aa96c67975ab6e1f3fa63ccea155e /subprojects/language/src/main/java/tools | |
parent | refactor(language): merge Assertion and AssertionAction (diff) | |
download | refinery-9fba55097010c5c57af35d9752517bad2a6d32a6.tar.gz refinery-9fba55097010c5c57af35d9752517bad2a6d32a6.tar.zst refinery-9fba55097010c5c57af35d9752517bad2a6d32a6.zip |
feat(language): more extensive rule validation
Diffstat (limited to 'subprojects/language/src/main/java/tools')
-rw-r--r-- | subprojects/language/src/main/java/tools/refinery/language/validation/ProblemValidator.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/subprojects/language/src/main/java/tools/refinery/language/validation/ProblemValidator.java b/subprojects/language/src/main/java/tools/refinery/language/validation/ProblemValidator.java index 0285c0c8..7b392182 100644 --- a/subprojects/language/src/main/java/tools/refinery/language/validation/ProblemValidator.java +++ b/subprojects/language/src/main/java/tools/refinery/language/validation/ProblemValidator.java | |||
@@ -340,11 +340,20 @@ public class ProblemValidator extends AbstractProblemValidator { | |||
340 | public void checkParameter(Parameter parameter) { | 340 | public void checkParameter(Parameter parameter) { |
341 | checkArity(parameter, ProblemPackage.Literals.PARAMETER__PARAMETER_TYPE, 1); | 341 | checkArity(parameter, ProblemPackage.Literals.PARAMETER__PARAMETER_TYPE, 1); |
342 | var parametricDefinition = EcoreUtil2.getContainerOfType(parameter, ParametricDefinition.class); | 342 | var parametricDefinition = EcoreUtil2.getContainerOfType(parameter, ParametricDefinition.class); |
343 | if (parametricDefinition instanceof RuleDefinition) { | 343 | if (parametricDefinition instanceof RuleDefinition rule) { |
344 | if (parameter.getParameterType() != null && parameter.getModality() == Modality.NONE) { | 344 | if (parameter.getParameterType() != null && parameter.getModality() == Modality.NONE) { |
345 | acceptError("Parameter type modality must be specified.", parameter, | 345 | acceptError("Parameter type modality must be specified.", parameter, |
346 | ProblemPackage.Literals.PARAMETER__PARAMETER_TYPE, 0, INVALID_MODALITY_ISSUE); | 346 | ProblemPackage.Literals.PARAMETER__PARAMETER_TYPE, 0, INVALID_MODALITY_ISSUE); |
347 | } | 347 | } |
348 | var kind = rule.getKind(); | ||
349 | var binding = parameter.getBinding(); | ||
350 | if (kind == RuleKind.PROPAGATION && binding != ParameterBinding.SINGLE) { | ||
351 | acceptError("Parameter binding annotations are not supported in propagation rules.", parameter, | ||
352 | ProblemPackage.Literals.PARAMETER__BINDING, 0, INVALID_MODALITY_ISSUE); | ||
353 | } else if (kind != RuleKind.DECISION && binding == ParameterBinding.MULTI) { | ||
354 | acceptError("Explicit multi-object bindings are only supported in decision rules.", parameter, | ||
355 | ProblemPackage.Literals.PARAMETER__BINDING, 0, INVALID_MODALITY_ISSUE); | ||
356 | } | ||
348 | } else { | 357 | } else { |
349 | if (parameter.getConcreteness() != Concreteness.PARTIAL || parameter.getModality() != Modality.NONE) { | 358 | if (parameter.getConcreteness() != Concreteness.PARTIAL || parameter.getModality() != Modality.NONE) { |
350 | acceptError("Modal parameter types are only supported in rule definitions.", parameter, null, 0, | 359 | acceptError("Modal parameter types are only supported in rule definitions.", parameter, null, 0, |