package EDU.neu.ccs.demeter.tools.apstudio.graphedit;
import java.awt.*;
import java.io.*;
import java.util.*;
import EDU.neu.ccs.demeter.*;
import EDU.neu.ccs.demeter.common.tg.*;


import EDU.neu.ccs.demeter.*;
class __V_PathDirective_toGraph {
  protected ClassName source;
  public ClassName get_source() { return source; }
  public void set_source(ClassName new_source)
    { source = new_source; }
  protected StrategyGraph return_val;
  public StrategyGraph get_return_val() { return return_val; }
  public void set_return_val(StrategyGraph new_return_val)
    { return_val = new_return_val; }
  __V_PathDirective_toGraph() { super(); }
  public __V_PathDirective_toGraph(ClassName source, StrategyGraph return_val) {
    super();
    set_source(source);
    set_return_val(return_val);
  }
 SGEdge edge = new SGEdge();   public void before(PathDirective host) {
      return_val = new StrategyGraph();
      ClassGlobSpec sourcespec = OneClassGlob.parse(source.toString());
      return_val.set_sources(sourcespec);
      return_val.set_sourceEdges(Integer_NList.parse("0"));
      edge.set_source(sourcespec);
    }
  public void before(NegativeConstraint host) {
      edge.set_constraint(host);
    }
  public void before(PositiveConstraint host) {
      GlobSpec glob = host.get_glob();
      ClassGlobSpec cglob = glob.collectClassGlobs();
      GlobSpec eglob = glob.collectEdgeGlobs();
      if (eglob != null) {
	System.err.println("Error: edge globs not yet supported.");
      } else if (cglob != null) {
	edge.set_dest(cglob);
	return_val.addEdge(edge);
	edge = new SGEdge();
	edge.set_source(cglob);
      }
    }
  public void before(ToStop host) {
      // Bypass all outgoing edges from the targets.
      Bypassing constraint = new Bypassing();
      constraint.set_glob(host.get_targets().toOutgoingEdgeSpec());
      edge.set_constraint(constraint.intersectWith(edge.get_constraint()));
    }
  public void after(TargetDirective host) {
      ClassGlobSpec targets = host.get_targets();
      edge.set_dest(targets);
      return_val.addEdge(edge);
      return_val.set_targets(targets);
    }
  public void start() {}
  public void finish() {}
}

