r220679 - clang-format: [Proto] Change formatting text-formatted options.
Daniel Jasper
djasper at google.com
Mon Oct 27 06:25:59 PDT 2014
Author: djasper
Date: Mon Oct 27 08:25:59 2014
New Revision: 220679
URL: http://llvm.org/viewvc/llvm-project?rev=220679&view=rev
Log:
clang-format: [Proto] Change formatting text-formatted options.
Before:
optional Type type = 1 [(mutate_options) = {vital : true
abc : false}];
After:
optional Type type = 1 [(mutate_options) = {
vital : true
abc : false
}];
Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestProto.cpp
Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=220679&r1=220678&r2=220679&view=diff
==============================================================================
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Mon Oct 27 08:25:59 2014
@@ -150,8 +150,7 @@ bool ContinuationIndenter::mustBreak(con
Previous.Type != TT_InlineASMColon &&
Previous.Type != TT_ConditionalExpr && nextIsMultilineString(State))
return true;
- if (Style.Language != FormatStyle::LK_Proto &&
- ((Previous.Type == TT_DictLiteral && Previous.is(tok::l_brace)) ||
+ if (((Previous.Type == TT_DictLiteral && Previous.is(tok::l_brace)) ||
Previous.Type == TT_ArrayInitializerLSquare) &&
Style.ColumnLimit > 0 &&
getLengthToMatchingParen(Previous) + State.Column > getColumnLimit(State))
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=220679&r1=220678&r2=220679&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Oct 27 08:25:59 2014
@@ -1768,7 +1768,7 @@ bool TokenAnnotator::mustBreakBefore(con
return Right.NewlinesBefore > 0;
} else if (Right.Previous->is(tok::l_brace) && Right.NestingLevel == 1 &&
Style.Language == FormatStyle::LK_Proto) {
- // Don't enums onto single lines in protocol buffers.
+ // Don't put enums onto single lines in protocol buffers.
return true;
} else if (Style.Language == FormatStyle::LK_JavaScript &&
Right.is(tok::r_brace) && Left.is(tok::l_brace) &&
Modified: cfe/trunk/unittests/Format/FormatTestProto.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestProto.cpp?rev=220679&r1=220678&r2=220679&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestProto.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestProto.cpp Mon Oct 27 08:25:59 2014
@@ -85,16 +85,19 @@ TEST_F(FormatTestProto, MessageFieldAttr
" [default = REALLY_REALLY_LONG_CONSTANT_VALUE];");
verifyFormat("repeated double value = 1\n"
" [(aaaaaaa.aaaaaaaaa) = {aaaaaaaaaaaaaaaaa: AAAAAAAA}];");
- verifyFormat("repeated double value = 1\n"
- " [(aaaaaaa.aaaaaaaaa) = {aaaaaaaaaaaaaaaa: AAAAAAAAAA,\n"
- " bbbbbbbbbbbbbbbb: BBBBBBBBBB}];");
- verifyFormat("repeated double value = 1\n"
- " [(aaaaaaa.aaaaaaaaa) = {aaaaaaaaaaaaaaaa: AAAAAAAAAA\n"
- " bbbbbbbbbbbbbbbb: BBBBBBBBBB}];");
- verifyFormat("repeated double value = 1\n"
- " [(aaaaaaa.aaaaaaaaa) = {aaaaaaaaaaaaaaaa: AAAAAAAAAA,\n"
- " bbbbbbb: BBBB,\n"
- " bbbb: BBB}];");
+ verifyFormat("repeated double value = 1 [(aaaaaaa.aaaaaaaaa) = {\n"
+ " aaaaaaaaaaaaaaaa: AAAAAAAAAA,\n"
+ " bbbbbbbbbbbbbbbb: BBBBBBBBBB\n"
+ "}];");
+ verifyFormat("repeated double value = 1 [(aaaaaaa.aaaaaaaaa) = {\n"
+ " aaaaaaaaaaaaaaaa: AAAAAAAAAA\n"
+ " bbbbbbbbbbbbbbbb: BBBBBBBBBB\n"
+ "}];");
+ verifyFormat("repeated double value = 1 [(aaaaaaa.aaaaaaaaa) = {\n"
+ " aaaaaaaaaaaaaaaa: AAAAAAAAAA,\n"
+ " bbbbbbb: BBBB,\n"
+ " bbbb: BBB\n"
+ "}];");
}
TEST_F(FormatTestProto, FormatsOptions) {
@@ -109,8 +112,10 @@ TEST_F(FormatTestProto, FormatsOptions)
" field_a: OK\n"
" field_b: \"OK\"\n"
" field_c: \"OK\"\n"
- " msg_field: {field_d: 123\n"
- " field_e: OK}\n"
+ " msg_field: {\n"
+ " field_d: 123\n"
+ " field_e: OK\n"
+ " }\n"
"};");
verifyFormat("option (MyProto.options) = {\n"
More information about the cfe-commits
mailing list