clang-format: Properly format custom options in protocol buffer definitions.

Before:
  option(my_option) = "abc";

After:
  option (my_option) = "abc";

llvm-svn: 199672
This commit is contained in:
Daniel Jasper 2014-01-20 16:47:22 +00:00
parent 3f5f3e7949
commit 929b1db276
2 changed files with 7 additions and 1 deletions

View File

@ -1254,7 +1254,8 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
const FormatToken &Left,
const FormatToken &Right) {
if (Style.Language == FormatStyle::LK_Proto) {
if (Right.is(tok::l_paren) && Left.TokenText == "returns")
if (Right.is(tok::l_paren) &&
(Left.TokenText == "returns" || Left.TokenText == "option"))
return true;
}
if (Right.is(tok::hashhash))

View File

@ -68,5 +68,10 @@ TEST_F(FormatTestProto, MessageFieldAttributes) {
" [default = REALLY_REALLY_LONG_CONSTANT_VALUE];");
}
TEST_F(FormatTestProto, FormatsOptions) {
verifyFormat("option java_package = \"my.test.package\";");
verifyFormat("option (my_custom_option) = \"abc\";");
}
} // end namespace tooling
} // end namespace clang