forked from OSchip/llvm-project
clang-format: [proto] Understand text-format nesting without :
Before: option (MyProto.options) = { field_c : "OK" msg_field{field_d : 123} }; After: option (MyProto.options) = { field_c : "OK" msg_field{field_d : 123} }; (Note that the colon after "msg_field" is optional). llvm-svn: 215692
This commit is contained in:
parent
e3981b8fac
commit
497d9fdcf8
|
@ -311,10 +311,12 @@ private:
|
|||
if (CurrentToken->isOneOf(tok::r_paren, tok::r_square))
|
||||
return false;
|
||||
updateParameterCount(Left, CurrentToken);
|
||||
if (CurrentToken->is(tok::colon)) {
|
||||
if (CurrentToken->getPreviousNonComment()->is(tok::identifier))
|
||||
CurrentToken->getPreviousNonComment()->Type = TT_SelectorName;
|
||||
Left->Type = TT_DictLiteral;
|
||||
if (CurrentToken->isOneOf(tok::colon, tok::l_brace)) {
|
||||
FormatToken *Previous = CurrentToken->getPreviousNonComment();
|
||||
if (Previous->is(tok::identifier))
|
||||
Previous->Type = TT_SelectorName;
|
||||
if (CurrentToken->is(tok::colon))
|
||||
Left->Type = TT_DictLiteral;
|
||||
}
|
||||
if (!consumeToken())
|
||||
return false;
|
||||
|
|
|
@ -119,6 +119,11 @@ TEST_F(FormatTestProto, FormatsOptions) {
|
|||
" field_c: \"OK\"\n"
|
||||
" msg_field: {field_d: 123}\n"
|
||||
"};");
|
||||
|
||||
verifyFormat("option (MyProto.options) = {\n"
|
||||
" field_c: \"OK\"\n"
|
||||
" msg_field{field_d: 123}\n"
|
||||
"};");
|
||||
}
|
||||
|
||||
TEST_F(FormatTestProto, FormatsService) {
|
||||
|
|
Loading…
Reference in New Issue