[PATCH] D43465: [clang-format] Fixup a case of text proto message attributes

Krasimir Georgiev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 19 07:33:44 PST 2018


This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rC325509: [clang-format] Fixup a case of text proto message attributes (authored by krasimir, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D43465?vs=134910&id=134912#toc

Repository:
  rC Clang

https://reviews.llvm.org/D43465

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestProto.cpp


Index: unittests/Format/FormatTestProto.cpp
===================================================================
--- unittests/Format/FormatTestProto.cpp
+++ unittests/Format/FormatTestProto.cpp
@@ -168,6 +168,16 @@
                "    aaaaaaaaaaaaaaaa: true\n"
                "  }\n"
                "];");
+  verifyFormat("extensions 20 [(proto2.type) = 'Aaaa.bbbb'];");
+  verifyFormat("extensions 20\n"
+               "    [(proto3.type) = 'Aaaa.bbbb', (aaa.Aaa) = 'aaa.bbb'];");
+  verifyFormat("extensions 123 [\n"
+               "  (aaa) = aaaa,\n"
+               "  (bbbbbbbbbbbbbbbbbbbbbbbbbb) = {\n"
+               "    aaaaaaaaaaaaaaaaa: true,\n"
+               "    aaaaaaaaaaaaaaaa: true\n"
+               "  }\n"
+               "];");
 }
 
 TEST_F(FormatTestProto, DoesntWrapFileOptions) {
Index: lib/Format/TokenAnnotator.cpp
===================================================================
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -375,6 +375,10 @@
         //   (aaa) = aaa
         // ];
         //
+        // extensions 123 [
+        //   (aaa) = aaa
+        // ];
+        //
         // or text proto extensions (in options):
         //
         // option (Aaa.options) = {
@@ -394,6 +398,8 @@
         Left->Type = TT_ArrayInitializerLSquare;
         if (!Left->endsSequence(tok::l_square, tok::numeric_constant,
                                 tok::equal) &&
+            !Left->endsSequence(tok::l_square, tok::numeric_constant,
+                                tok::identifier) &&
             !Left->endsSequence(tok::l_square, tok::colon, TT_SelectorName)) {
           Left->Type = TT_ProtoExtensionLSquare;
           BindingIncrease = 10;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43465.134912.patch
Type: text/x-patch
Size: 1717 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180219/4a6eaf12/attachment.bin>


More information about the cfe-commits mailing list