@@ -41,6 +41,9 @@ void printNode(Node n) {
41
41
} else if (n instanceof Statement ) {
42
42
printStmt ((Statement ) n );
43
43
44
+ } else if (n instanceof Comprehension .Clause ) {
45
+ printClause ((Comprehension .Clause ) n );
46
+
44
47
} else if (n instanceof StarlarkFile ) {
45
48
StarlarkFile file = (StarlarkFile ) n ;
46
49
// Only statements are printed, not comments.
@@ -277,17 +280,7 @@ private void printExpr(Expression expr) {
277
280
printNode (comp .getBody ()); // Expression or DictExpression.Entry
278
281
for (Comprehension .Clause clause : comp .getClauses ()) {
279
282
buf .append (' ' );
280
- if (clause instanceof Comprehension .For ) {
281
- Comprehension .For forClause = (Comprehension .For ) clause ;
282
- buf .append ("for " );
283
- printExpr (forClause .getVars ());
284
- buf .append (" in " );
285
- printExpr (forClause .getIterable ());
286
- } else {
287
- Comprehension .If ifClause = (Comprehension .If ) clause ;
288
- buf .append ("if " );
289
- printExpr (ifClause .getCondition ());
290
- }
283
+ printClause (clause );
291
284
}
292
285
buf .append (comp .isDict () ? '}' : ']' );
293
286
break ;
@@ -482,4 +475,18 @@ private void printExpr(Expression expr) {
482
475
}
483
476
}
484
477
}
478
+
479
+ private void printClause (Comprehension .Clause clause ) {
480
+ if (clause instanceof Comprehension .For ) {
481
+ Comprehension .For forClause = (Comprehension .For ) clause ;
482
+ buf .append ("for " );
483
+ printExpr (forClause .getVars ());
484
+ buf .append (" in " );
485
+ printExpr (forClause .getIterable ());
486
+ } else {
487
+ Comprehension .If ifClause = (Comprehension .If ) clause ;
488
+ buf .append ("if " );
489
+ printExpr (ifClause .getCondition ());
490
+ }
491
+ }
485
492
}
0 commit comments