Search in sources :

Example 1 with Browsable

use of edu.mit.csail.sdg.ast.Browsable in project org.alloytools.alloy by AlloyTools.

the class CompModule method getSubnodes.

/**
 * {@inheritDoc}
 */
@Override
public List<? extends Browsable> getSubnodes() {
    ArrayList<Browsable> ans = new ArrayList<Browsable>();
    ArrayList<Browsable> x;
    if (opens.size() > 0) {
        x = new ArrayList<Browsable>(opens.size());
        for (Open e : opens.values()) if (!x.contains(e.realModule))
            x.add(e.realModule);
        ans.add(make("<b>" + x.size() + (x.size() > 1 ? " opens</b>" : " open</b>"), x));
    }
    if (sigs.size() > 0) {
        x = new ArrayList<Browsable>(sigs.values());
        ans.add(make("<b>" + x.size() + (x.size() > 1 ? " sigs</b>" : " sig</b>"), x));
    }
    if (funcs.size() > 0) {
        ArrayList<Browsable> x2 = new ArrayList<Browsable>(funcs.size());
        x = new ArrayList<Browsable>(funcs.size());
        for (ArrayList<Func> e : funcs.values()) for (Func f : e) if (f.isPred)
            x.add(f);
        else
            x2.add(f);
        if (x.size() > 0)
            ans.add(make("<b>" + x.size() + (x.size() > 1 ? " preds</b>" : " pred</b>"), x));
        if (x2.size() > 0)
            ans.add(make("<b>" + x2.size() + (x2.size() > 1 ? " funs</b>" : " fun</b>"), x2));
    }
    if (commands.size() > 0) {
        ArrayList<Browsable> x2 = new ArrayList<Browsable>(commands.size());
        x = new ArrayList<Browsable>(commands.size());
        for (Command e : commands) if (e.check)
            x.add(e);
        else
            x2.add(e);
        if (x.size() > 0)
            ans.add(make("<b>" + x.size() + (x.size() > 1 ? " checks</b>" : " check</b>"), x));
        if (x2.size() > 0)
            ans.add(make("<b>" + x2.size() + (x2.size() > 1 ? " runs</b>" : " run</b>"), x2));
    }
    if (facts.size() > 0) {
        x = new ArrayList<Browsable>(facts.size());
        for (Pair<String, Expr> e : facts) x.add(make(e.b.span(), e.b.span(), "<b>fact " + e.a + "</b>", e.b));
        ans.add(make("<b>" + x.size() + (x.size() > 1 ? " facts</b>" : " fact</b>"), x));
    }
    if (asserts.size() > 0) {
        x = new ArrayList<Browsable>(asserts.size());
        for (Map.Entry<String, Expr> e : asserts.entrySet()) {
            Pos sp = e.getValue().span();
            x.add(make(sp, sp, "<b>assert</b> " + e.getKey(), e.getValue()));
        }
        ans.add(make("<b>" + x.size() + (x.size() > 1 ? " asserts</b>" : " assert</b>"), x));
    }
    return ans;
}
Also used : Browsable(edu.mit.csail.sdg.ast.Browsable) Func(edu.mit.csail.sdg.ast.Func) ArrayList(java.util.ArrayList) Expr(edu.mit.csail.sdg.ast.Expr) Command(edu.mit.csail.sdg.ast.Command) Pos(edu.mit.csail.sdg.alloy4.Pos) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with Browsable

use of edu.mit.csail.sdg.ast.Browsable in project org.alloytools.alloy by AlloyTools.

the class SimpleGUI method do_action.

/**
 * {@inheritDoc}
 */
@Override
public Object do_action(Object sender, Event e, Object arg) {
    if (sender instanceof OurTree && e == Event.CLICK && arg instanceof Browsable) {
        Pos p = ((Browsable) arg).pos();
        if (p == Pos.UNKNOWN)
            p = ((Browsable) arg).span();
        text.shade(p);
    }
    return true;
}
Also used : Browsable(edu.mit.csail.sdg.ast.Browsable) Pos(edu.mit.csail.sdg.alloy4.Pos) OurTree(edu.mit.csail.sdg.alloy4.OurTree)

Aggregations

Pos (edu.mit.csail.sdg.alloy4.Pos)2 Browsable (edu.mit.csail.sdg.ast.Browsable)2 OurTree (edu.mit.csail.sdg.alloy4.OurTree)1 Command (edu.mit.csail.sdg.ast.Command)1 Expr (edu.mit.csail.sdg.ast.Expr)1 Func (edu.mit.csail.sdg.ast.Func)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1