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

llvm-svn: 211488
This commit is contained in:
Daniel Jasper 2014-06-23 07:36:25 +00:00
parent 32ccb03871
commit 9c2820c4e3
2 changed files with 7 additions and 0 deletions

View 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;

View File

@ -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"