]> granicus.if.org Git - clang/commitdiff
[clang-format] Fix text proto extension scope opening detection
authorKrasimir Georgiev <krasimir@google.com>
Mon, 19 Feb 2018 16:00:21 +0000 (16:00 +0000)
committerKrasimir Georgiev <krasimir@google.com>
Mon, 19 Feb 2018 16:00:21 +0000 (16:00 +0000)
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

lib/Format/FormatToken.h
unittests/Format/FormatTestTextProto.cpp

index 6a558875619ac0d1c1651361507c91a132939682..550bdccfb69b5198b368fe72fa1e6ce0838bac18 100644 (file)
@@ -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))) ||
index 97326cfe0ac0af56cbd568097bcb36be2e12e223..17cde61d2af983e144af973fab2f06618959eadd 100644 (file)
@@ -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) {