diff options
author | 2024-05-20 17:29:07 +0200 | |
---|---|---|
committer | 2024-05-26 17:22:33 +0200 | |
commit | 42214746edac8bdc992a52ca8624f996871e2842 (patch) | |
tree | 2e8cf18ab0a9b12fcba96b2eb7511cd84131cb57 /subprojects/language/src/main/java/tools | |
parent | feat(dse): detect stuch propagation rules (diff) | |
download | refinery-42214746edac8bdc992a52ca8624f996871e2842.tar.gz refinery-42214746edac8bdc992a52ca8624f996871e2842.tar.zst refinery-42214746edac8bdc992a52ca8624f996871e2842.zip |
feat(language): node constants in rule actions
Diffstat (limited to 'subprojects/language/src/main/java/tools')
-rw-r--r-- | subprojects/language/src/main/java/tools/refinery/language/validation/ProblemValidator.java | 18 |
1 files changed, 17 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 7b392182..84af4ee6 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 | |||
@@ -153,6 +153,22 @@ public class ProblemValidator extends AbstractProblemValidator { | |||
153 | } | 153 | } |
154 | 154 | ||
155 | @Check | 155 | @Check |
156 | public void checkNodeAssertionArgumentConstants(NodeAssertionArgument argument) { | ||
157 | var rule = EcoreUtil2.getContainerOfType(argument, RuleDefinition.class); | ||
158 | if (rule == null) { | ||
159 | return; | ||
160 | } | ||
161 | var variableOrNode = argument.getNode(); | ||
162 | if (variableOrNode instanceof Node node && !ProblemUtil.isAtomNode(node)) { | ||
163 | var name = node.getName(); | ||
164 | var message = ("Only atoms can be referenced in rule actions. " + | ||
165 | "Mark '%s' as an atom with the declaration 'atom %s.'").formatted(name, name); | ||
166 | error(message, argument, ProblemPackage.Literals.NODE_ASSERTION_ARGUMENT__NODE, | ||
167 | INSIGNIFICANT_INDEX, NODE_CONSTANT_ISSUE); | ||
168 | } | ||
169 | } | ||
170 | |||
171 | @Check | ||
156 | public void checkUniqueDeclarations(Problem problem) { | 172 | public void checkUniqueDeclarations(Problem problem) { |
157 | var relations = new ArrayList<Relation>(); | 173 | var relations = new ArrayList<Relation>(); |
158 | var nodes = new ArrayList<Node>(); | 174 | var nodes = new ArrayList<Node>(); |
@@ -360,7 +376,7 @@ public class ProblemValidator extends AbstractProblemValidator { | |||
360 | INVALID_MODALITY_ISSUE); | 376 | INVALID_MODALITY_ISSUE); |
361 | } | 377 | } |
362 | if (parameter.getBinding() != ParameterBinding.SINGLE) { | 378 | if (parameter.getBinding() != ParameterBinding.SINGLE) { |
363 | acceptError("Parameter binding annotations are only supported in rule definitions.", parameter, | 379 | acceptError("Parameter binding annotations are only supported in decision rules.", parameter, |
364 | ProblemPackage.PARAMETER__BINDING, 0, INVALID_MODALITY_ISSUE); | 380 | ProblemPackage.PARAMETER__BINDING, 0, INVALID_MODALITY_ISSUE); |
365 | } | 381 | } |
366 | } | 382 | } |