Skip to content

Commit 2ebc859

Browse files
committed
Split constraints from the CONSTRAINTS section and predicates from the REQUIRES section
1 parent 8ca2c86 commit 2ebc859

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

CrySLParser/src/main/java/crysl/parsing/CrySLModelReader.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,8 @@ private CrySLRule createRuleFromDomainModel(Domainmodel model) throws CrySLParse
235235
final Order order = orderBlock == null ? null : orderBlock.getOrder();
236236
this.smg = StateMachineGraphBuilder.buildSMG(order, events);
237237

238-
final Collection<ISLConstraint> constraints = new ArrayList<>();
239-
constraints.addAll(getConstraints(model.getConstraints()));
240-
constraints.addAll(getRequiredPredicates(model.getRequires()));
238+
Collection<ISLConstraint> constraints = getConstraints(model.getConstraints());
239+
Collection<ISLConstraint> requiredPredicates = getRequiredPredicates(model.getRequires());
241240

242241
// Since 3.0.0: All sections are optional
243242
final Collection<CrySLMethod> eventMethods = new HashSet<>();
@@ -261,6 +260,7 @@ private CrySLRule createRuleFromDomainModel(Domainmodel model) throws CrySLParse
261260
eventMethods,
262261
this.smg,
263262
constraints,
263+
requiredPredicates,
264264
predicates,
265265
negatedPredicates);
266266
}

CrySLParser/src/main/java/crysl/rule/CrySLRule.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package crysl.rule;
22

33
import java.util.Collection;
4-
import java.util.LinkedList;
54
import java.util.Map;
65

76
public class CrySLRule {
@@ -18,6 +17,8 @@ public class CrySLRule {
1817

1918
private final Collection<ISLConstraint> constraints;
2019

20+
private final Collection<ISLConstraint> requiredPredicates;
21+
2122
private final Collection<CrySLPredicate> predicates;
2223

2324
private final Collection<CrySLPredicate> negatedPredicates;
@@ -29,6 +30,7 @@ public CrySLRule(
2930
Collection<CrySLMethod> events,
3031
StateMachineGraph usagePattern,
3132
Collection<ISLConstraint> constraints,
33+
Collection<ISLConstraint> requiredPredicates,
3234
Collection<CrySLPredicate> predicates,
3335
Collection<CrySLPredicate> negatedPredicates) {
3436
this.className = className;
@@ -37,6 +39,7 @@ public CrySLRule(
3739
this.events = events;
3840
this.usagePattern = usagePattern;
3941
this.constraints = constraints;
42+
this.requiredPredicates = requiredPredicates;
4043
this.predicates = predicates;
4144
this.negatedPredicates = negatedPredicates;
4245
}
@@ -113,14 +116,8 @@ public Collection<CrySLPredicate> getNegatedPredicates() {
113116
/**
114117
* @return the constraints
115118
*/
116-
public Collection<CrySLPredicate> getRequiredPredicates() {
117-
Collection<CrySLPredicate> requires = new LinkedList<>();
118-
for (ISLConstraint con : constraints) {
119-
if (con instanceof CrySLPredicate) {
120-
requires.add((CrySLPredicate) con);
121-
}
122-
}
123-
return requires;
119+
public Collection<ISLConstraint> getRequiredPredicates() {
120+
return requiredPredicates;
124121
}
125122

126123
@Override

0 commit comments

Comments
 (0)