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;
}
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;
}
Aggregations