--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java Wed Jul 23 09:19:23 2014 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java Thu Jul 24 13:11:03 2014 +0100
@@ -29,6 +29,7 @@
import com.sun.tools.javac.tree.JCTree.JCTypeCast;
import com.sun.tools.javac.tree.TreeInfo;
import com.sun.tools.javac.util.*;
+import com.sun.tools.javac.util.GraphUtils.DottableNode;
import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.code.*;
@@ -40,9 +41,9 @@
import com.sun.tools.javac.comp.Infer.GraphSolver.InferenceGraph.Node;
import com.sun.tools.javac.comp.Resolve.InapplicableMethodException;
import com.sun.tools.javac.comp.Resolve.VerboseResolutionMode;
-import com.sun.tools.javac.util.GraphUtils.TarjanNode;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.EnumMap;
import java.util.EnumSet;
@@ -50,6 +51,7 @@
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Map;
+import java.util.Properties;
import java.util.Set;
import static com.sun.tools.javac.code.TypeTag.*;
@@ -1607,11 +1609,6 @@
private DependencyKind(String dotSyle) {
this.dotSyle = dotSyle;
}
-
- @Override
- public String getDotStyle() {
- return dotSyle;
- }
}
/**
@@ -1684,7 +1681,7 @@
* updates on the structure of the graph this node belongs to (used to
* keep dependencies in sync).
*/
- class Node extends GraphUtils.TarjanNode<ListBuffer<Type>> {
+ class Node extends GraphUtils.TarjanNode<ListBuffer<Type>, Node> implements DottableNode<ListBuffer<Type>, Node> {
/** map listing all dependencies (grouped by kind) */
EnumMap<DependencyKind, Set<Node>> deps;
@@ -1699,33 +1696,12 @@
return DependencyKind.values();
}
- @Override
- public String getDependencyName(GraphUtils.Node<ListBuffer<Type>> to, GraphUtils.DependencyKind dk) {
- if (dk == DependencyKind.STUCK) return "";
- else {
- StringBuilder buf = new StringBuilder();
- String sep = "";
- for (Type from : data) {
- UndetVar uv = (UndetVar)inferenceContext.asUndetVar(from);
- for (Type bound : uv.getBounds(InferenceBound.values())) {
- if (bound.containsAny(List.from(to.data))) {
- buf.append(sep);
- buf.append(bound);
- sep = ",";
- }
- }
- }
- return buf.toString();
- }
- }
-
- @Override
public Iterable<? extends Node> getAllDependencies() {
return getDependencies(DependencyKind.values());
}
@Override
- public Iterable<? extends TarjanNode<ListBuffer<Type>>> getDependenciesByKind(GraphUtils.DependencyKind dk) {
+ public Collection<? extends Node> getDependenciesByKind(GraphUtils.DependencyKind dk) {
return getDependencies((DependencyKind)dk);
}
@@ -1855,6 +1831,36 @@
}
}
}
+
+ @Override
+ public Properties nodeAttributes() {
+ Properties p = new Properties();
+ p.put("label", toString());
+ return p;
+ }
+
+ @Override
+ public Properties dependencyAttributes(Node sink, GraphUtils.DependencyKind dk) {
+ Properties p = new Properties();
+ p.put("style", ((DependencyKind)dk).dotSyle);
+ if (dk == DependencyKind.STUCK) return p;
+ else {
+ StringBuilder buf = new StringBuilder();
+ String sep = "";
+ for (Type from : data) {
+ UndetVar uv = (UndetVar)inferenceContext.asUndetVar(from);
+ for (Type bound : uv.getBounds(InferenceBound.values())) {
+ if (bound.containsAny(List.from(sink.data))) {
+ buf.append(sep);
+ buf.append(bound);
+ sep = ",";
+ }
+ }
+ }
+ p.put("label", buf.toString());
+ }
+ return p;
+ }
}
/** the nodes in the inference graph */