Skip to content
Snippets Groups Projects
Commit d1ee17a6 authored by Daniel Jasper's avatar Daniel Jasper
Browse files

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

Before:
  option(my_option) = "abc";

After:
  option (my_option) = "abc";

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199672 91177308-0d34-0410-b5e6-96231b3b80d8
parent 6a1431e9
No related branches found
No related tags found
No related merge requests found
......@@ -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))
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment