use of mb.nabl2.constraints.scopegraph.CGDirectEdge in project nabl by metaborg.
the class ScopeGraphComponent method solve.
private boolean solve(CGDirectEdge c) {
ITerm sourceScopeRep = unifier().findRecursive(c.getSourceScope());
if (!sourceScopeRep.isGround()) {
return false;
}
Scope sourceScope = Scope.matcher().match(sourceScopeRep, unifier()).orElseThrow(() -> new TypeException("Expected a scope but got " + sourceScopeRep));
return findScope(c.getTargetScope()).map(targetScope -> {
scopeGraph.addDirectEdge(sourceScope, c.getLabel(), targetScope);
return true;
}).orElseGet(() -> {
scopeGraph.addIncompleteDirectEdge(sourceScope, c.getLabel(), c.getTargetScope());
return true;
});
}
Aggregations