1.1 --- a/src/share/classes/com/sun/tools/javac/util/GraphUtils.java Fri Aug 30 17:36:47 2013 -0700 1.2 +++ b/src/share/classes/com/sun/tools/javac/util/GraphUtils.java Mon Sep 02 22:38:36 2013 +0100 1.3 @@ -33,6 +33,18 @@ 1.4 public class GraphUtils { 1.5 1.6 /** 1.7 + * Basic interface for defining various dependency kinds. All dependency kinds 1.8 + * must at least support basic capabilities to tell the DOT engine how to render them. 1.9 + */ 1.10 + public interface DependencyKind { 1.11 + /** 1.12 + * Returns the DOT representation (to be used in a {@code style} attribute 1.13 + * that's most suited for this dependency kind. 1.14 + */ 1.15 + String getDotStyle(); 1.16 + } 1.17 + 1.18 + /** 1.19 * This class is a basic abstract class for representing a node. 1.20 * A node is associated with a given data. 1.21 */ 1.22 @@ -43,9 +55,20 @@ 1.23 this.data = data; 1.24 } 1.25 1.26 - public abstract Iterable<? extends Node<D>> getDependencies(); 1.27 + /** 1.28 + * Get an array of the dependency kinds supported by this node. 1.29 + */ 1.30 + public abstract DependencyKind[] getSupportedDependencyKinds(); 1.31 1.32 - public abstract String printDependency(Node<D> to); 1.33 + /** 1.34 + * Get all dependencies, regardless of their kind. 1.35 + */ 1.36 + public abstract Iterable<? extends Node<D>> getAllDependencies(); 1.37 + 1.38 + /** 1.39 + * Get a name for the dependency (of given kind) linking this node to a given node 1.40 + */ 1.41 + public abstract String getDependencyName(Node<D> to, DependencyKind dk); 1.42 1.43 @Override 1.44 public String toString() { 1.45 @@ -66,7 +89,9 @@ 1.46 super(data); 1.47 } 1.48 1.49 - public abstract Iterable<? extends TarjanNode<D>> getDependencies(); 1.50 + public abstract Iterable<? extends TarjanNode<D>> getAllDependencies(); 1.51 + 1.52 + public abstract Iterable<? extends TarjanNode<D>> getDependenciesByKind(DependencyKind dk); 1.53 1.54 public int compareTo(TarjanNode<D> o) { 1.55 return (index < o.index) ? -1 : (index == o.index) ? 0 : 1; 1.56 @@ -95,7 +120,7 @@ 1.57 index++; 1.58 stack.prepend(v); 1.59 v.active = true; 1.60 - for (TarjanNode<D> nd: v.getDependencies()) { 1.61 + for (TarjanNode<D> nd: v.getAllDependencies()) { 1.62 @SuppressWarnings("unchecked") 1.63 N n = (N)nd; 1.64 if (n.index == -1) { 1.65 @@ -134,9 +159,11 @@ 1.66 } 1.67 //dump arcs 1.68 for (TarjanNode<D> from : nodes) { 1.69 - for (TarjanNode<D> to : from.getDependencies()) { 1.70 - buf.append(String.format("%s -> %s [label = \" %s \"];\n", 1.71 - from.hashCode(), to.hashCode(), from.printDependency(to))); 1.72 + for (DependencyKind dk : from.getSupportedDependencyKinds()) { 1.73 + for (TarjanNode<D> to : from.getDependenciesByKind(dk)) { 1.74 + buf.append(String.format("%s -> %s [label = \" %s \" style = %s ];\n", 1.75 + from.hashCode(), to.hashCode(), from.getDependencyName(to, dk), dk.getDotStyle())); 1.76 + } 1.77 } 1.78 } 1.79 buf.append("}\n");