File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -1499,6 +1499,34 @@ class FormatWalker : public ASTWalker {
1499
1499
return IndentContext {ContextLoc, false };
1500
1500
}
1501
1501
1502
+ if (auto *ECD = dyn_cast<EnumCaseDecl>(D)) {
1503
+ SourceLoc CaseLoc = ECD->getLoc ();
1504
+
1505
+ if (TrailingTarget)
1506
+ return None;
1507
+
1508
+ ListAligner Aligner (SM, TargetLocation, CaseLoc, CaseLoc);
1509
+ for (auto *Elem: ECD->getElements ()) {
1510
+ SourceRange ElemRange = Elem->getSourceRange ();
1511
+ Aligner.updateAlignment (ElemRange, Elem);
1512
+ }
1513
+ return Aligner.getContextAndSetAlignment (CtxOverride);
1514
+ }
1515
+
1516
+ if (auto *EED = dyn_cast<EnumElementDecl>(D)) {
1517
+ SourceLoc ContextLoc = EED->getStartLoc ();
1518
+ if (auto Ctx = getIndentContextFrom (EED->getParameterList ()))
1519
+ return Ctx;
1520
+
1521
+ if (TrailingTarget)
1522
+ return None;
1523
+
1524
+ return IndentContext {
1525
+ ContextLoc,
1526
+ !OutdentChecker::hasOutdent (SM, EED)
1527
+ };
1528
+ }
1529
+
1502
1530
if (auto *SD = dyn_cast<SubscriptDecl>(D)) {
1503
1531
SourceLoc ContextLoc = SD->getStartLoc ();
1504
1532
Original file line number Diff line number Diff line change @@ -83,6 +83,27 @@ bax(34949494949)
83
83
. baz
84
84
85
85
86
+ // Enum element parameters should be aligned, and raw values should be indented.
87
+
88
+ enum TestEnum {
89
+ case first( x: Int ,
90
+ y: Int ,
91
+ z: Int ) ,
92
+ second(
93
+ x: Int ,
94
+ y: Int
95
+ )
96
+ case third
97
+ }
98
+
99
+ enum RawEnum : String {
100
+ case aCaseWithAParticularlyLongNameSoTheValueIsWrapped =
101
+ " a long message here " ,
102
+ aNotherCaseWithAParticularlyLongNameSoTheValueIsWrapped =
103
+ " a long message here "
104
+ }
105
+
106
+
86
107
// Condition elements should align with each other.
87
108
//
88
109
guard let x = Optional . some ( 10 ) , x > 100 ,
You can’t perform that action at this time.
0 commit comments