19
19
import com .google .common .collect .Iterables ;
20
20
import com .google .common .collect .Ordering ;
21
21
import com .google .devtools .build .lib .cmdline .Label ;
22
+ import com .google .devtools .build .lib .cmdline .RepositoryMapping ;
22
23
import com .google .devtools .build .lib .collect .CollectionUtils ;
23
24
import com .google .devtools .build .lib .collect .EquivalenceRelation ;
24
25
import com .google .devtools .build .lib .graph .Digraph ;
@@ -54,7 +55,7 @@ public interface NodeReader<T> {
54
55
* <p>This is not the same as a build {@link Label}. This is just the text associated with a
55
56
* node in a GraphViz graph.
56
57
*/
57
- String getLabel (Node <T > node );
58
+ String getLabel (Node <T > node , RepositoryMapping mainRepositoryMapping );
58
59
59
60
/** Returns a comparator for the build graph nodes that form the payloads of GraphViz nodes. */
60
61
Comparator <T > comparator ();
@@ -67,6 +68,7 @@ public interface NodeReader<T> {
67
68
private final int maxConditionalEdges ;
68
69
private final boolean mergeEquivalentNodes ;
69
70
private final Ordering <Node <T >> nodeComparator ;
71
+ private final RepositoryMapping mainRepoMapping ;
70
72
71
73
private static final int RESERVED_LABEL_CHARS = "\\ n...and 9999999 more items" .length ();
72
74
@@ -90,13 +92,15 @@ public GraphOutputWriter(
90
92
boolean sortLabels ,
91
93
int maxLabelSize ,
92
94
int maxConditionalEdges ,
93
- boolean mergeEquivalentNodes ) {
95
+ boolean mergeEquivalentNodes ,
96
+ RepositoryMapping mainRepoMapping ) {
94
97
this .nodeReader = nodeReader ;
95
98
this .lineTerminator = lineTerminator ;
96
99
this .sortLabels = sortLabels ;
97
100
this .maxLabelSize = maxLabelSize ;
98
101
this .maxConditionalEdges = maxConditionalEdges ;
99
102
this .mergeEquivalentNodes = mergeEquivalentNodes ;
103
+ this .mainRepoMapping = mainRepoMapping ;
100
104
nodeComparator = Ordering .from (nodeReader .comparator ()).onResultOf (Node ::getLabel );
101
105
}
102
106
@@ -120,7 +124,7 @@ public void write(
120
124
private void outputUnfactored (
121
125
Digraph <T > graph , @ Nullable ConditionalEdges conditionalEdges , PrintWriter out ) {
122
126
graph .visitNodesBeforeEdges (
123
- new DotOutputVisitor <T >(out , nodeReader :: getLabel ) {
127
+ new DotOutputVisitor <T >(out , node -> nodeReader . getLabel ( node , mainRepoMapping ) ) {
124
128
@ Override
125
129
public void beginVisit () {
126
130
super .beginVisit ();
@@ -180,7 +184,7 @@ private void outputFactored(
180
184
StringBuilder buf = new StringBuilder ();
181
185
int count = 0 ;
182
186
for (Node <T > eqNode : node .getLabel ()) {
183
- String labelString = nodeReader .getLabel (eqNode );
187
+ String labelString = nodeReader .getLabel (eqNode , mainRepoMapping );
184
188
if (!firstItem ) {
185
189
buf .append ("\\ n" );
186
190
0 commit comments