diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index fdad75917c64c0e89bf2b09597551847d1af7bad..3793fe056ed2f92d88496d417431809b3df6dd71 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 6506a6dc0b7e872d93376435ff458d7150c7bb99..bfd502566757e49793dfc6d46ad5133b663374f9 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"