In proto, enum constants can contain complex options and should be
handled more like individual declarations.
Before:
enum Type {
UNKNOWN = 0 [(some_options) =
{
a: aa,
b: bb
}];
};
After:
enum Type {
UNKNOWN = 0 [(some_options) = {
a: aa,
b: bb
}];
};
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@242404
91177308-0d34-0410-b5e6-
96231b3b80d8
// parseEnum falls through and does not yet add an unwrapped line as an
// enum definition can start a structural element.
parseEnum();
- // This does not apply for Java and JavaScript.
- if (Style.Language == FormatStyle::LK_Java ||
- Style.Language == FormatStyle::LK_JavaScript) {
+ // This only applies for C++.
+ if (Style.Language != FormatStyle::LK_Cpp) {
addUnwrappedLine();
return;
}
// Java enums are different.
parseJavaEnumBody();
return;
+ } else if (Style.Language == FormatStyle::LK_Proto) {
+ parseBlock(/*MustBeDeclaration=*/true);
+ return;
}
// Parse enum body.
" TYPE_A = 1;\n"
" TYPE_B = 2;\n"
"};");
+ verifyFormat("enum Type {\n"
+ " UNKNOWN = 0 [(some_options) = {\n"
+ " a: aa,\n"
+ " b: bb\n"
+ " }];\n"
+ "};");
}
TEST_F(FormatTestProto, UnderstandsReturns) {