diff options
author | 2024-05-22 19:08:06 +0200 | |
---|---|---|
committer | 2024-05-26 17:22:33 +0200 | |
commit | 2589b2522170ae1e63c310a7e41a22edad0f9dd2 (patch) | |
tree | 706efee0dd60c014473358bfb154bb76177f106d /subprojects/language/src/main/java/tools | |
parent | fix(language): spurious exception in ProblemValidator (diff) | |
download | refinery-2589b2522170ae1e63c310a7e41a22edad0f9dd2.tar.gz refinery-2589b2522170ae1e63c310a7e41a22edad0f9dd2.tar.zst refinery-2589b2522170ae1e63c310a7e41a22edad0f9dd2.zip |
fix(language): validate unique rule names
Diffstat (limited to 'subprojects/language/src/main/java/tools')
2 files changed, 7 insertions, 1 deletions
diff --git a/subprojects/language/src/main/java/tools/refinery/language/resource/ProblemResourceDescriptionStrategy.java b/subprojects/language/src/main/java/tools/refinery/language/resource/ProblemResourceDescriptionStrategy.java index 8fd60364..505c7787 100644 --- a/subprojects/language/src/main/java/tools/refinery/language/resource/ProblemResourceDescriptionStrategy.java +++ b/subprojects/language/src/main/java/tools/refinery/language/resource/ProblemResourceDescriptionStrategy.java | |||
@@ -154,6 +154,9 @@ public class ProblemResourceDescriptionStrategy extends DefaultResourceDescripti | |||
154 | if (ProblemUtil.isTypeLike(relation)) { | 154 | if (ProblemUtil.isTypeLike(relation)) { |
155 | builder.put(TYPE_LIKE, TYPE_LIKE_TRUE); | 155 | builder.put(TYPE_LIKE, TYPE_LIKE_TRUE); |
156 | } | 156 | } |
157 | } else if (eObject instanceof RuleDefinition) { | ||
158 | // Rule definitions and predicates live in the same namespace. | ||
159 | builder.put(SHADOWING_KEY, SHADOWING_KEY_RELATION); | ||
157 | } else if (eObject instanceof AggregatorDeclaration) { | 160 | } else if (eObject instanceof AggregatorDeclaration) { |
158 | builder.put(SHADOWING_KEY, SHADOWING_KEY_AGGREGATOR); | 161 | builder.put(SHADOWING_KEY, SHADOWING_KEY_AGGREGATOR); |
159 | } | 162 | } |
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 0d35fb03..9f5fdeae 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 | |||
@@ -170,12 +170,15 @@ public class ProblemValidator extends AbstractProblemValidator { | |||
170 | 170 | ||
171 | @Check | 171 | @Check |
172 | public void checkUniqueDeclarations(Problem problem) { | 172 | public void checkUniqueDeclarations(Problem problem) { |
173 | var relations = new ArrayList<Relation>(); | 173 | var relations = new ArrayList<NamedElement>(); |
174 | var nodes = new ArrayList<Node>(); | 174 | var nodes = new ArrayList<Node>(); |
175 | var aggregators = new ArrayList<AggregatorDeclaration>(); | 175 | var aggregators = new ArrayList<AggregatorDeclaration>(); |
176 | for (var statement : problem.getStatements()) { | 176 | for (var statement : problem.getStatements()) { |
177 | if (statement instanceof Relation relation) { | 177 | if (statement instanceof Relation relation) { |
178 | relations.add(relation); | 178 | relations.add(relation); |
179 | } else if (statement instanceof RuleDefinition ruleDefinition) { | ||
180 | // Rule definitions and predicates live in the same namespace. | ||
181 | relations.add(ruleDefinition); | ||
179 | } else if (statement instanceof NodeDeclaration nodeDeclaration) { | 182 | } else if (statement instanceof NodeDeclaration nodeDeclaration) { |
180 | nodes.addAll(nodeDeclaration.getNodes()); | 183 | nodes.addAll(nodeDeclaration.getNodes()); |
181 | } else if (statement instanceof AggregatorDeclaration aggregatorDeclaration) { | 184 | } else if (statement instanceof AggregatorDeclaration aggregatorDeclaration) { |