From 3e7aa0d2fa1a131a18706a214fa9dacbe09f56a4 Mon Sep 17 00:00:00 2001 From: Daniel Jasper <djasper@google.com> Date: Mon, 23 Jun 2014 07:36:25 +0000 Subject: [PATCH] clang-format: [proto] Add required space before absolute references. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211488 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/TokenAnnotator.cpp | 4 ++++ unittests/Format/FormatTestProto.cpp | 3 +++ 2 files changed, 7 insertions(+) diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index fdad75917c6..3793fe056ed 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/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/unittests/Format/FormatTestProto.cpp b/unittests/Format/FormatTestProto.cpp index 6506a6dc0b7..bfd50256675 100644 --- a/unittests/Format/FormatTestProto.cpp +++ b/unittests/Format/FormatTestProto.cpp @@ -46,6 +46,9 @@ TEST_F(FormatTestProto, FormatsMessages) { verifyFormat("message SomeMessage {\n" " 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" -- GitLab