use of de.be4.classicalb.core.parser.rules.AbstractOperation in project probparsers by bendisposto.
the class AbstractOperation method getRequiredDependencies.
public Set<AbstractOperation> getRequiredDependencies() {
if (this.requiredDependencies == null) {
this.requiredDependencies = new HashSet<>();
HashSet<AIdentifierExpression> aIdentifierSet = new HashSet<>();
aIdentifierSet.addAll(this.dependsOnComputationList);
aIdentifierSet.addAll(this.dependsOnRuleList);
HashSet<String> directDependencies = new HashSet<>();
for (AIdentifierExpression aIdentifier : aIdentifierSet) {
directDependencies.add(aIdentifier.getIdentifier().get(0).getText());
}
if (transitiveDependencies != null) {
for (AbstractOperation abstractOperation : this.transitiveDependencies) {
String opName = abstractOperation.getName();
if (this.implicitDependenciesToComputations.contains(abstractOperation) || directDependencies.contains(opName)) {
requiredDependencies.add(abstractOperation);
} else if (functionCallMap.containsKey(opName)) {
requiredDependencies.addAll(abstractOperation.getRequiredDependencies());
}
}
}
}
return new HashSet<>(requiredDependencies);
}
use of de.be4.classicalb.core.parser.rules.AbstractOperation in project probparsers by bendisposto.
the class RulesProject method checkForCycles.
private boolean checkForCycles(AbstractOperation operation, List<TIdentifierLiteral> directDependencies, List<AbstractOperation> ancestors) {
List<String> ancestorsNames = new ArrayList<>();
for (AbstractOperation op : ancestors) {
String opName = op.getName();
ancestorsNames.add(opName);
}
for (TIdentifierLiteral id : directDependencies) {
final String opName = id.getText();
if (ancestorsNames.contains(opName)) {
StringBuilder sb = new StringBuilder();
for (int index = ancestorsNames.indexOf(opName); index < ancestors.size(); index++) {
final String name = ancestors.get(index).getName();
sb.append(name);
sb.append(" -> ");
}
sb.append(opName);
this.bExceptionList.add(new BException(operation.getFileName(), new CheckException("Cyclic dependencies between operations: " + sb.toString(), id)));
return true;
}
}
return false;
}
use of de.be4.classicalb.core.parser.rules.AbstractOperation in project probparsers by bendisposto.
the class RulesProject method checkDependsOnComputations.
private void checkDependsOnComputations(AbstractOperation operation) {
boolean errorOccured = false;
for (AIdentifierExpression aIdentifierExpression : operation.getDependsOnComputationList()) {
final String name = aIdentifierExpression.getIdentifier().get(0).getText();
if (allOperations.containsKey(name)) {
AbstractOperation abstractOperation = allOperations.get(name);
if (!(abstractOperation instanceof ComputationOperation)) {
this.bExceptionList.add(new BException(operation.getFileName(), new CheckException("Identifier '" + name + "' is not a COMPUTATION.", aIdentifierExpression)));
errorOccured = true;
}
} else {
errorOccured = true;
this.bExceptionList.add(new BException(operation.getFileName(), new CheckException("Unknown operation: '" + name + "'.", aIdentifierExpression)));
}
}
if (!errorOccured) {
checkVisibilityOfAIdentifierList(operation, operation.getDependsOnComputationList());
}
}
use of de.be4.classicalb.core.parser.rules.AbstractOperation in project probparsers by bendisposto.
the class RulesProject method checkDependsOnRules.
private void checkDependsOnRules(AbstractOperation operation) {
boolean errorOccured = false;
for (AIdentifierExpression aIdentifierExpression : operation.getDependsOnRulesList()) {
final String name = aIdentifierExpression.getIdentifier().get(0).getText();
if (allOperations.containsKey(name)) {
AbstractOperation abstractOperation = allOperations.get(name);
if (!(abstractOperation instanceof RuleOperation)) {
this.bExceptionList.add(new BException(operation.getFileName(), new CheckException("Operation '" + name + "' is not a RULE operation.", aIdentifierExpression)));
errorOccured = true;
}
} else {
errorOccured = true;
this.bExceptionList.add(new BException(operation.getFileName(), new CheckException("Unknown operation: '" + name + "'.", aIdentifierExpression)));
}
}
if (!errorOccured) {
checkVisibilityOfAIdentifierList(operation, operation.getDependsOnRulesList());
}
}
use of de.be4.classicalb.core.parser.rules.AbstractOperation in project probparsers by bendisposto.
the class RulesProject method checkVisibilityOfAIdentifierList.
private void checkVisibilityOfAIdentifierList(AbstractOperation operation, List<AIdentifierExpression> dependencyList) {
List<TIdentifierLiteral> tidentifierList = new ArrayList<>();
for (AIdentifierExpression aIdentifier : dependencyList) {
tidentifierList.add(aIdentifier.getIdentifier().get(0));
}
checkVisibilityOfTIdentifierList(operation, tidentifierList);
}
Aggregations