Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split constraints from the CONSTRAINTS section and predicates from th… #139

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading