Skip to content

Commit

Permalink
Split constraints from the CONSTRAINTS section and predicates from th…
Browse files Browse the repository at this point in the history
…e REQUIRES section
  • Loading branch information
smeyer198 committed Jan 8, 2025
1 parent 8ca2c86 commit 2ebc859
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
6 changes: 3 additions & 3 deletions CrySLParser/src/main/java/crysl/parsing/CrySLModelReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,8 @@ private CrySLRule createRuleFromDomainModel(Domainmodel model) throws CrySLParse
final Order order = orderBlock == null ? null : orderBlock.getOrder();
this.smg = StateMachineGraphBuilder.buildSMG(order, events);

final Collection<ISLConstraint> constraints = new ArrayList<>();
constraints.addAll(getConstraints(model.getConstraints()));
constraints.addAll(getRequiredPredicates(model.getRequires()));
Collection<ISLConstraint> constraints = getConstraints(model.getConstraints());
Collection<ISLConstraint> requiredPredicates = getRequiredPredicates(model.getRequires());

// Since 3.0.0: All sections are optional
final Collection<CrySLMethod> eventMethods = new HashSet<>();
Expand All @@ -261,6 +260,7 @@ private CrySLRule createRuleFromDomainModel(Domainmodel model) throws CrySLParse
eventMethods,
this.smg,
constraints,
requiredPredicates,
predicates,
negatedPredicates);
}
Expand Down
15 changes: 6 additions & 9 deletions CrySLParser/src/main/java/crysl/rule/CrySLRule.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package crysl.rule;

import java.util.Collection;
import java.util.LinkedList;
import java.util.Map;

public class CrySLRule {
Expand All @@ -18,6 +17,8 @@ public class CrySLRule {

private final Collection<ISLConstraint> constraints;

private final Collection<ISLConstraint> requiredPredicates;

private final Collection<CrySLPredicate> predicates;

private final Collection<CrySLPredicate> negatedPredicates;
Expand All @@ -29,6 +30,7 @@ public CrySLRule(
Collection<CrySLMethod> events,
StateMachineGraph usagePattern,
Collection<ISLConstraint> constraints,
Collection<ISLConstraint> requiredPredicates,
Collection<CrySLPredicate> predicates,
Collection<CrySLPredicate> negatedPredicates) {
this.className = className;
Expand All @@ -37,6 +39,7 @@ public CrySLRule(
this.events = events;
this.usagePattern = usagePattern;
this.constraints = constraints;
this.requiredPredicates = requiredPredicates;
this.predicates = predicates;
this.negatedPredicates = negatedPredicates;
}
Expand Down Expand Up @@ -113,14 +116,8 @@ public Collection<CrySLPredicate> getNegatedPredicates() {
/**
* @return the constraints
*/
public Collection<CrySLPredicate> getRequiredPredicates() {
Collection<CrySLPredicate> requires = new LinkedList<>();
for (ISLConstraint con : constraints) {
if (con instanceof CrySLPredicate) {
requires.add((CrySLPredicate) con);
}
}
return requires;
public Collection<ISLConstraint> getRequiredPredicates() {
return requiredPredicates;
}

@Override
Expand Down

0 comments on commit 2ebc859

Please sign in to comment.