diff options
| author | Daniel Jasper <djasper@google.com> | 2014-06-23 07:36:25 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2014-06-23 07:36:25 +0000 |
| commit | 9c2820c4e35baadc2061dcbdadde2bf060ee013b (patch) | |
| tree | 7bc5b89f1a62b8518d85c3546f204419baebebfd | |
| parent | 32ccb03871a06985dee32955c83406411e206257 (diff) | |
| download | bcm5719-llvm-9c2820c4e35baadc2061dcbdadde2bf060ee013b.tar.gz bcm5719-llvm-9c2820c4e35baadc2061dcbdadde2bf060ee013b.zip | |
clang-format: [proto] Add required space before absolute references.
llvm-svn: 211488
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 4 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTestProto.cpp | 3 |
2 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index fdad75917c6..3793fe056ed 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -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; diff --git a/clang/unittests/Format/FormatTestProto.cpp b/clang/unittests/Format/FormatTestProto.cpp index 6506a6dc0b7..bfd50256675 100644 --- a/clang/unittests/Format/FormatTestProto.cpp +++ b/clang/unittests/Format/FormatTestProto.cpp @@ -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" "}"); |

