forked from OSchip/llvm-project
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:
parent
3f5f3e7949
commit
929b1db276
|
@ -1254,7 +1254,8 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
|
||||||
const FormatToken &Left,
|
const FormatToken &Left,
|
||||||
const FormatToken &Right) {
|
const FormatToken &Right) {
|
||||||
if (Style.Language == FormatStyle::LK_Proto) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
if (Right.is(tok::hashhash))
|
if (Right.is(tok::hashhash))
|
||||||
|
|
|
@ -68,5 +68,10 @@ TEST_F(FormatTestProto, MessageFieldAttributes) {
|
||||||
" [default = REALLY_REALLY_LONG_CONSTANT_VALUE];");
|
" [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 tooling
|
||||||
} // end namespace clang
|
} // end namespace clang
|
||||||
|
|
Loading…
Reference in New Issue