Summary:
Top-level "package" and "import" statements should generally be kept on
one line, for all languages.
----
This reverts commit rL356912.
The regression from rL356835 was fixed via rC358275.
Reviewers: krasimir, sammccall, MyDeveloperDay, xinz, dchai, klimek
Reviewed By: krasimir, xinz, dchai
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D60661
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@360411
91177308-0d34-0410-b5e6-
96231b3b80d8
return LT_ImportStatement;
}
- // In .proto files, top-level options are very similar to import statements
- // and should not be line-wrapped.
+ // In .proto files, top-level options and package statements are very
+ // similar to import statements and should not be line-wrapped.
if (Style.Language == FormatStyle::LK_Proto && Line.Level == 0 &&
- CurrentToken->is(Keywords.kw_option)) {
+ CurrentToken->isOneOf(Keywords.kw_option, Keywords.kw_package)) {
next();
if (CurrentToken && CurrentToken->is(tok::identifier)) {
while (CurrentToken)
"};");
}
+TEST_F(FormatTestProto, DoesntWrapPackageStatements) {
+ verifyFormat(
+ "package"
+ " some.really.long.package.that.exceeds.the.column.limit00000000;");
+}
+
+TEST_F(FormatTestProto, TrailingCommentAfterPackage) {
+ verifyFormat("package foo.pkg; // comment\n");
+}
+
TEST_F(FormatTestProto, FormatsService) {
verifyFormat("service SearchService {\n"
" rpc Search(SearchRequest) returns (SearchResponse) {\n"