[PATCH] D59627: [clang-format] Keep protobuf "package" statement on one line
Phabricator via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 23 07:44:43 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356835: [clang-format] Keep protobuf "package" statement on one line (authored by paulhoad, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D59627/new/
https://reviews.llvm.org/D59627
Files:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestProto.cpp
Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/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))
return LT_ImportStatement;
Index: cfe/trunk/unittests/Format/FormatTestProto.cpp
===================================================================
--- cfe/trunk/unittests/Format/FormatTestProto.cpp
+++ cfe/trunk/unittests/Format/FormatTestProto.cpp
@@ -393,6 +393,12 @@
"};");
}
+TEST_F(FormatTestProto, DoesntWrapPackageStatements) {
+ verifyFormat(
+ "package"
+ " some.really.long.package.that.exceeds.the.column.limit00000000;");
+}
+
TEST_F(FormatTestProto, FormatsService) {
verifyFormat("service SearchService {\n"
" rpc Search(SearchRequest) returns (SearchResponse) {\n"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59627.191998.patch
Type: text/x-patch
Size: 1449 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190323/982234b1/attachment.bin>
More information about the cfe-commits
mailing list