@@ -2615,88 +2615,94 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
2615
2615
printCommon (E, " keypath_expr" );
2616
2616
if (E->isObjC ())
2617
2617
OS << " objc" ;
2618
+
2619
+ OS << ' \n ' ;
2620
+ Indent += 2 ;
2621
+ OS.indent (Indent);
2622
+ PrintWithColorRAII (OS, ParenthesisColor) << ' (' ;
2623
+ PrintWithColorRAII (OS, ExprColor) << " components" ;
2624
+ OS.indent (Indent + 2 );
2618
2625
for (unsigned i : indices (E->getComponents ())) {
2619
2626
auto &component = E->getComponents ()[i];
2620
2627
OS << ' \n ' ;
2621
2628
OS.indent (Indent + 2 );
2622
- OS << " (component= " ;
2629
+ PrintWithColorRAII (OS, ParenthesisColor) << ' ( ' ;
2623
2630
switch (component.getKind ()) {
2624
2631
case KeyPathExpr::Component::Kind::Invalid:
2625
- OS << " invalid " ;
2632
+ PrintWithColorRAII (OS, ASTNodeColor) << " invalid" ;
2626
2633
break ;
2627
2634
2628
2635
case KeyPathExpr::Component::Kind::OptionalChain:
2629
- OS << " optional_chain " ;
2636
+ PrintWithColorRAII (OS, ASTNodeColor) << " optional_chain" ;
2630
2637
break ;
2631
2638
2632
2639
case KeyPathExpr::Component::Kind::OptionalForce:
2633
- OS << " optional_force " ;
2640
+ PrintWithColorRAII (OS, ASTNodeColor) << " optional_force" ;
2634
2641
break ;
2635
2642
2636
2643
case KeyPathExpr::Component::Kind::OptionalWrap:
2637
- OS << " optional_wrap " ;
2644
+ PrintWithColorRAII (OS, ASTNodeColor) << " optional_wrap" ;
2638
2645
break ;
2639
2646
2640
2647
case KeyPathExpr::Component::Kind::Property:
2641
- OS << " property " ;
2648
+ PrintWithColorRAII (OS, ASTNodeColor) << " property" ;
2649
+ PrintWithColorRAII (OS, DeclColor) << " decl=" ;
2642
2650
printDeclRef (component.getDeclRef ());
2643
- OS << " " ;
2644
2651
break ;
2645
2652
2646
2653
case KeyPathExpr::Component::Kind::Subscript:
2647
- OS << " subscript " ;
2654
+ PrintWithColorRAII (OS, ASTNodeColor) << " subscript" ;
2655
+ PrintWithColorRAII (OS, DeclColor) << " decl='" ;
2648
2656
printDeclRef (component.getDeclRef ());
2649
- OS << ' \n ' ;
2650
- Indent += 2 ;
2651
- printRec (component.getIndexExpr ());
2652
- Indent -= 2 ;
2653
- OS.indent (Indent + 4 );
2657
+ PrintWithColorRAII (OS, DeclColor) << " '" ;
2654
2658
break ;
2655
2659
2656
2660
case KeyPathExpr::Component::Kind::UnresolvedProperty:
2657
- OS << " unresolved_property " ;
2658
- component. getUnresolvedDeclName (). print (OS);
2659
- OS << " " ;
2661
+ PrintWithColorRAII (OS, ASTNodeColor) << " unresolved_property" ;
2662
+ PrintWithColorRAII (OS, IdentifierColor)
2663
+ << " decl_name=' " << component. getUnresolvedDeclName () << " ' " ;
2660
2664
break ;
2661
2665
2662
2666
case KeyPathExpr::Component::Kind::UnresolvedSubscript:
2663
- OS << " unresolved_subscript" ;
2664
- OS << ' \n ' ;
2665
- Indent += 2 ;
2666
- printRec (component.getIndexExpr ());
2667
- Indent -= 2 ;
2668
- OS.indent (Indent + 4 );
2667
+ PrintWithColorRAII (OS, ASTNodeColor) << " unresolved_subscript" ;
2668
+ printArgumentLabels (component.getSubscriptLabels ());
2669
2669
break ;
2670
2670
case KeyPathExpr::Component::Kind::Identity:
2671
- OS << " identity" ;
2672
- OS << ' \n ' ;
2671
+ PrintWithColorRAII (OS, ASTNodeColor) << " identity" ;
2673
2672
break ;
2673
+
2674
2674
case KeyPathExpr::Component::Kind::TupleElement:
2675
- OS << " tuple_element " ;
2676
- OS << " # " << component. getTupleIndex ();
2677
- OS << " " ;
2675
+ PrintWithColorRAII (OS, ASTNodeColor) << " tuple_element " ;
2676
+ PrintWithColorRAII (OS, DiscriminatorColor)
2677
+ << " # " << component. getTupleIndex () ;
2678
2678
break ;
2679
2679
}
2680
- OS << " type=" ;
2681
- GetTypeOfKeyPathComponent (E, i).print (OS);
2680
+ PrintWithColorRAII (OS, TypeColor)
2681
+ << " type='" << GetTypeOfKeyPathComponent (E, i) << " '" ;
2682
+ if (auto indexExpr = component.getIndexExpr ()) {
2683
+ OS << ' \n ' ;
2684
+ Indent += 2 ;
2685
+ printRec (indexExpr);
2686
+ Indent -= 2 ;
2687
+ }
2682
2688
PrintWithColorRAII (OS, ParenthesisColor) << ' )' ;
2683
2689
}
2690
+
2691
+ PrintWithColorRAII (OS, ParenthesisColor) << ' )' ;
2692
+ Indent -= 2 ;
2693
+
2684
2694
if (auto stringLiteral = E->getObjCStringLiteralExpr ()) {
2685
2695
OS << ' \n ' ;
2686
- printRec (stringLiteral);
2696
+ printRecLabeled (stringLiteral, " objc_string_literal " );
2687
2697
}
2688
2698
if (!E->isObjC ()) {
2689
- OS << " \n " ;
2690
2699
if (auto root = E->getParsedRoot ()) {
2691
- printRec (root);
2692
- } else {
2693
- OS.indent (Indent + 2 ) << " <<null>>" ;
2700
+ OS << " \n " ;
2701
+ printRecLabeled (root, " parsed_root" );
2694
2702
}
2695
- OS << " \n " ;
2696
2703
if (auto path = E->getParsedPath ()) {
2697
- printRec (path);
2698
- } else {
2699
- OS.indent (Indent + 2 ) << " <<null>>" ;
2704
+ OS << " \n " ;
2705
+ printRecLabeled (path, " parsed_path" );
2700
2706
}
2701
2707
}
2702
2708
PrintWithColorRAII (OS, ParenthesisColor) << ' )' ;
0 commit comments