clang-format: Fix option formatting in protocol buffer files.

Before:
  optional int32 foo[ default = true, deprecated = true ];

After:
  optional int32 foo[default = true, deprecated = true];

llvm-svn: 200327
This commit is contained in:
Daniel Jasper 2014-01-28 18:51:11 +00:00
parent 5fdb09bb76
commit a0e9be2bb2
2 changed files with 5 additions and 0 deletions

View File

@ -248,6 +248,7 @@ private:
if (CurrentToken->is(tok::colon))
ColonFound = true;
if (CurrentToken->is(tok::comma) &&
Style.Language != FormatStyle::LK_Proto &&
(Left->Type == TT_ArraySubscriptLSquare ||
(Left->Type == TT_ObjCMethodExpr && !ColonFound)))
Left->Type = TT_ArrayInitializerLSquare;

View File

@ -74,6 +74,10 @@ TEST_F(FormatTestProto, UnderstandsReturns) {
TEST_F(FormatTestProto, MessageFieldAttributes) {
verifyFormat("optional string test = 1 [default = \"test\"];");
verifyFormat("optional bool a = 1 [default = true, deprecated = true];");
verifyFormat("optional LongMessageType long_proto_field = 1\n"
" [default = REALLY_REALLY_LONG_CONSTANT_VALUE,\n"
" deprecated = true];");
verifyFormat("optional LongMessageType long_proto_field = 1\n"
" [default = REALLY_REALLY_LONG_CONSTANT_VALUE];");
}