Search in sources :

Example 1 with CGImportEdge

use of mb.nabl2.constraints.scopegraph.CGImportEdge in project nabl by metaborg.

the class ScopeGraphComponent method solve.

private boolean solve(CGImportEdge c) {
    ITerm scopeRep = unifier().findRecursive(c.getScope());
    if (!scopeRep.isGround()) {
        return false;
    }
    Scope scope = Scope.matcher().match(scopeRep, unifier()).orElseThrow(() -> new TypeException("Expected a scope but got " + scopeRep));
    return findOccurrence(c.getReference()).map(ref -> {
        scopeGraph.addImportEdge(scope, c.getLabel(), ref);
        return true;
    }).orElseGet(() -> {
        scopeGraph.addIncompleteImportEdge(scope, c.getLabel(), c.getReference());
        return true;
    });
}
Also used : TypeException(mb.nabl2.solver.TypeException) ASolver(mb.nabl2.solver.ASolver) ITerm(mb.nabl2.terms.ITerm) CGDirectEdge(mb.nabl2.constraints.scopegraph.CGDirectEdge) IScopeGraphConstraint(mb.nabl2.constraints.scopegraph.IScopeGraphConstraint) IEsopScopeGraph(mb.nabl2.scopegraph.esop.IEsopScopeGraph) Scope(mb.nabl2.scopegraph.terms.Scope) CGExportEdge(mb.nabl2.constraints.scopegraph.CGExportEdge) Occurrence(mb.nabl2.scopegraph.terms.Occurrence) IMessageInfo(mb.nabl2.constraints.messages.IMessageInfo) CGRef(mb.nabl2.constraints.scopegraph.CGRef) SolveResult(mb.nabl2.solver.ISolver.SolveResult) SolverCore(mb.nabl2.solver.SolverCore) CGDecl(mb.nabl2.constraints.scopegraph.CGDecl) ISolver(mb.nabl2.solver.ISolver) Label(mb.nabl2.scopegraph.terms.Label) SeedResult(mb.nabl2.solver.ISolver.SeedResult) CGImportEdge(mb.nabl2.constraints.scopegraph.CGImportEdge) Optional(java.util.Optional) Scope(mb.nabl2.scopegraph.terms.Scope) ITerm(mb.nabl2.terms.ITerm) TypeException(mb.nabl2.solver.TypeException)

Aggregations

Optional (java.util.Optional)1 IMessageInfo (mb.nabl2.constraints.messages.IMessageInfo)1 CGDecl (mb.nabl2.constraints.scopegraph.CGDecl)1 CGDirectEdge (mb.nabl2.constraints.scopegraph.CGDirectEdge)1 CGExportEdge (mb.nabl2.constraints.scopegraph.CGExportEdge)1 CGImportEdge (mb.nabl2.constraints.scopegraph.CGImportEdge)1 CGRef (mb.nabl2.constraints.scopegraph.CGRef)1 IScopeGraphConstraint (mb.nabl2.constraints.scopegraph.IScopeGraphConstraint)1 IEsopScopeGraph (mb.nabl2.scopegraph.esop.IEsopScopeGraph)1 Label (mb.nabl2.scopegraph.terms.Label)1 Occurrence (mb.nabl2.scopegraph.terms.Occurrence)1 Scope (mb.nabl2.scopegraph.terms.Scope)1 ASolver (mb.nabl2.solver.ASolver)1 ISolver (mb.nabl2.solver.ISolver)1 SeedResult (mb.nabl2.solver.ISolver.SeedResult)1 SolveResult (mb.nabl2.solver.ISolver.SolveResult)1 SolverCore (mb.nabl2.solver.SolverCore)1 TypeException (mb.nabl2.solver.TypeException)1 ITerm (mb.nabl2.terms.ITerm)1