Revert "[clang-format] Keep protobuf "package" statement on one line"

This reverts commit r356835. This patch causes a regression, see the
test below:

verifyFormat("// Detached comment\n\n"
             "// Leading comment\n"
             "syntax = \"proto2\"; // trailing comment\n\n"
             "// in foo.bar package\n"
             "package foo.bar; // foo.bar package\n");

llvm-svn: 356912
This commit is contained in:
Haojian Wu 2019-03-25 15:46:07 +00:00
parent 040f94cc7e
commit ae3fefe397
2 changed files with 3 additions and 9 deletions

View File

@ -1119,10 +1119,10 @@ public:
return LT_ImportStatement; return LT_ImportStatement;
} }
// In .proto files, top-level options and package statements are very // In .proto files, top-level options are very similar to import statements
// similar to import statements and should not be line-wrapped. // and should not be line-wrapped.
if (Style.Language == FormatStyle::LK_Proto && Line.Level == 0 && if (Style.Language == FormatStyle::LK_Proto && Line.Level == 0 &&
CurrentToken->isOneOf(Keywords.kw_option, Keywords.kw_package)) { CurrentToken->is(Keywords.kw_option)) {
next(); next();
if (CurrentToken && CurrentToken->is(tok::identifier)) if (CurrentToken && CurrentToken->is(tok::identifier))
return LT_ImportStatement; return LT_ImportStatement;

View File

@ -393,12 +393,6 @@ TEST_F(FormatTestProto, FormatsOptions) {
"};"); "};");
} }
TEST_F(FormatTestProto, DoesntWrapPackageStatements) {
verifyFormat(
"package"
" some.really.long.package.that.exceeds.the.column.limit00000000;");
}
TEST_F(FormatTestProto, FormatsService) { TEST_F(FormatTestProto, FormatsService) {
verifyFormat("service SearchService {\n" verifyFormat("service SearchService {\n"
" rpc Search(SearchRequest) returns (SearchResponse) {\n" " rpc Search(SearchRequest) returns (SearchResponse) {\n"