r211488 - clang-format: [proto] Add required space before absolute references.

Daniel Jasper djasper at google.com
Mon Jun 23 00:36:26 PDT 2014


Author: djasper
Date: Mon Jun 23 02:36:25 2014
New Revision: 211488

URL: http://llvm.org/viewvc/llvm-project?rev=211488&view=rev
Log:
clang-format: [proto] Add required space before absolute references.

Modified:
    cfe/trunk/lib/Format/TokenAnnotator.cpp
    cfe/trunk/unittests/Format/FormatTestProto.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=211488&r1=211487&r2=211488&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Jun 23 02:36:25 2014
@@ -1406,6 +1406,10 @@ bool TokenAnnotator::spaceRequiredBetwee
                                           const FormatToken &Left,
                                           const FormatToken &Right) {
   if (Style.Language == FormatStyle::LK_Proto) {
+    if (Right.is(tok::period) &&
+        (Left.TokenText == "optional" || Left.TokenText == "required" ||
+         Left.TokenText == "repeated"))
+      return true;
     if (Right.is(tok::l_paren) &&
         (Left.TokenText == "returns" || Left.TokenText == "option"))
       return true;

Modified: cfe/trunk/unittests/Format/FormatTestProto.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestProto.cpp?rev=211488&r1=211487&r2=211488&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestProto.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestProto.cpp Mon Jun 23 02:36:25 2014
@@ -47,6 +47,9 @@ TEST_F(FormatTestProto, FormatsMessages)
                "  required int32 field1 = 1;\n"
                "}");
   verifyFormat("message SomeMessage {\n"
+               "  required .absolute.Reference field1 = 1;\n"
+               "}");
+  verifyFormat("message SomeMessage {\n"
                "  required int32 field1 = 1;\n"
                "  optional string field2 = 2 [default = \"2\"]\n"
                "}");





More information about the cfe-commits mailing list