use of mb.nabl2.constraints.sets.CEvalSet in project nabl by metaborg.
the class SetComponent method solve.
private Optional<SolveResult> solve(CEvalSet constraint) {
ITerm setTerm = unifier().findRecursive(constraint.getSet());
if (!setTerm.isGround()) {
return Optional.empty();
}
Optional<Set<IElement<ITerm>>> maybeSet = evaluator.match(setTerm, unifier());
if (!(maybeSet.isPresent())) {
return Optional.empty();
}
List<ITerm> set = maybeSet.get().stream().map(i -> unifier().findRecursive(i.getValue())).collect(Collectors.toList());
return Optional.of(SolveResult.constraints(ImmutableCEqual.of(constraint.getResult(), B.newList(set), constraint.getMessageInfo())));
}
Aggregations