clang-format: [proto] Add required space before absolute references.
authorDaniel Jasper <djasper@google.com>
Mon, 23 Jun 2014 07:36:25 +0000 (07:36 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 23 Jun 2014 07:36:25 +0000 (07:36 +0000)
llvm-svn: 211488

clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTestProto.cpp

index fdad759..3793fe0 100644 (file)
@@ -1406,6 +1406,10 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
                                           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;
index 6506a6d..bfd5025 100644 (file)
@@ -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"
                "}");