From: Krasimir Georgiev Date: Mon, 19 Feb 2018 16:00:21 +0000 (+0000) Subject: [clang-format] Fix text proto extension scope opening detection X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e7b23b3cb5e5146f8e882aa336fb4e556637dc27;p=clang [clang-format] Fix text proto extension scope opening detection Summary: This fixes the detection of scope openers in text proto extensions; previously they were not detected correctly leading to instances like: ``` msg { [aa.bb ] { key: value } } ``` Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D43469 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@325513 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/FormatToken.h b/lib/Format/FormatToken.h index 6a55887561..550bdccfb6 100644 --- a/lib/Format/FormatToken.h +++ b/lib/Format/FormatToken.h @@ -478,6 +478,7 @@ struct FormatToken { if (is(TT_TemplateString) && opensScope()) return true; return is(TT_ArrayInitializerLSquare) || + is(TT_ProtoExtensionLSquare) || (is(tok::l_brace) && (BlockKind == BK_Block || is(TT_DictLiteral) || (!Style.Cpp11BracedListStyle && NestingLevel == 0))) || diff --git a/unittests/Format/FormatTestTextProto.cpp b/unittests/Format/FormatTestTextProto.cpp index 97326cfe0a..17cde61d2a 100644 --- a/unittests/Format/FormatTestTextProto.cpp +++ b/unittests/Format/FormatTestTextProto.cpp @@ -389,6 +389,14 @@ TEST_F(FormatTestTextProto, FormatsExtensions) { " keyyyyyyyyyyyyyy: valuuuuuuuuuuuuuuuuuuuuuuuuue\n" " }\n" "}"); + verifyFormat( + "aaaaaaaaaaaaaaa {\n" + " bbbbbb {\n" + " [a.b/cy] {\n" + " eeeeeeeeeeeee: \"The lazy coo cat jumps over the lazy hot dog\"\n" + " }\n" + " }\n" + "}"); } TEST_F(FormatTestTextProto, NoSpaceAfterPercent) {