use of mb.nabl2.constraints.messages.IMessageInfo in project nabl by metaborg.
the class EqualityComponent method solve.
// ------------------------------------------------------------------------------------------------------//
private Optional<SolveResult> solve(CEqual constraint) {
final ITerm left = constraint.getLeft();
final ITerm right = constraint.getRight();
try {
final IUnifier.Transient unifier = this.unifier.get().melt();
final IUnifier.Immutable unifyResult = unifier.unify(left, right);
final SolveResult solveResult = ImmutableSolveResult.builder().unifierDiff(unifyResult).build();
this.unifier.set(unifier.freeze());
return Optional.of(solveResult);
} catch (UnificationException ex) {
final MessageContent content = MessageContent.builder().append("Cannot unify ").append(left).append(" with ").append(right).build();
final IMessageInfo message = (constraint.getMessageInfo().withDefaultContent(content));
final SolveResult solveResult = SolveResult.messages(message);
return Optional.of(solveResult);
}
}
Aggregations