core: import edu.neu.ccs.demeter.dj.*; import java.util.*; import edu.neu.ccs.demeter.*; add: class FlattenVisitor extends Visitor { public constructor FlattenVisitor() {{ super(); }} public static FlattenVisitor parse(java.io.Reader in) throws ParseException {{ return new Parser(in)._FlattenVisitor(); }} public static FlattenVisitor parse(java.io.InputStream in) throws ParseException {{ return new Parser(in)._FlattenVisitor(); }} public static FlattenVisitor parse(String s) {{ try { return parse(new java.io.StringReader(s)); } catch (ParseException e) { throw new RuntimeException(e.toString()); } }} {{ HashSet commonParents; // Names of classes to add common parts to HashSet commonChildren; // Common children to add to parent boolean debug = false; boolean flush = true; boolean parent = true; // To tell if parent or child class boolean add = false; FlattenVisitor(boolean d) { commonParents = new HashSet(); commonChildren = new HashSet(); debug = d; } void before(Adjacency host) { if (flush) { commonParents.clear(); commonChildren.clear(); } else { if (commonParents.contains(host.get_source())) { add = true; } } } void after(Adjacency host) { add = false; } void before(Neighbors_wc host) { if (add) { Iterator step = commonChildren.iterator(); while(step.hasNext()) host.get_construct_ns().addElement((Any_vertex)step.next()); } } void before(Neighbors host) { parent = false; } void after(Neighbors host) { parent = true; } void before(Common host) { flush = false; commonChildren.add(host); } void before(Vertex host) { if (!parent) commonParents.add(host); } }} {{ void universal_trv0_bef(UniversalVisitor _v_) { ((UniversalVisitor) _v_).before(this); } }} {{ void universal_trv0_aft(UniversalVisitor _v_) { ((UniversalVisitor) _v_).after(this); } }} {{ void universal_trv0(UniversalVisitor _v_) { universal_trv0_bef(_v_); universal_trv0_aft(_v_); } }} }