[PATCH] D60661: Revert "Revert "[clang-format] Keep protobuf "package" statement on one line""
Donald Chai via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Apr 13 21:31:21 PDT 2019
dchai created this revision.
dchai added a reviewer: krasimir.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Top-level "package" and "import" statements should generally be kept on
one line, for all languages.
----
This reverts commit rL356912 <https://reviews.llvm.org/rL356912>.
The regression from rL356835 <https://reviews.llvm.org/rL356835> was fixed via rC358275 <https://reviews.llvm.org/rC358275>.
Repository:
rC Clang
https://reviews.llvm.org/D60661
Files:
lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTestProto.cpp
Index: unittests/Format/FormatTestProto.cpp
===================================================================
--- unittests/Format/FormatTestProto.cpp
+++ unittests/Format/FormatTestProto.cpp
@@ -397,6 +397,16 @@
"};");
}
+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"
Index: lib/Format/TokenAnnotator.cpp
===================================================================
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1119,10 +1119,10 @@
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)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60661.195048.patch
Type: text/x-patch
Size: 1497 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190414/200bec1b/attachment.bin>
More information about the cfe-commits
mailing list