From 34b404d309a8610fe2729fe9a98f564486f3673c Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 25 Mar 2019 15:46:07 +0000 Subject: [PATCH] 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"); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356912 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/TokenAnnotator.cpp | 6 +++--- unittests/Format/FormatTestProto.cpp | 6 ------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index a3000a8fde..ccf5e51576 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -1119,10 +1119,10 @@ public: return LT_ImportStatement; } - // In .proto files, top-level options and package statements are very - // similar to import statements and should not be line-wrapped. + // In .proto files, top-level options are very similar to import statements + // and should not be line-wrapped. if (Style.Language == FormatStyle::LK_Proto && Line.Level == 0 && - CurrentToken->isOneOf(Keywords.kw_option, Keywords.kw_package)) { + CurrentToken->is(Keywords.kw_option)) { next(); if (CurrentToken && CurrentToken->is(tok::identifier)) return LT_ImportStatement; diff --git a/unittests/Format/FormatTestProto.cpp b/unittests/Format/FormatTestProto.cpp index fd4870c27f..d5683b5b84 100644 --- a/unittests/Format/FormatTestProto.cpp +++ b/unittests/Format/FormatTestProto.cpp @@ -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) { verifyFormat("service SearchService {\n" " rpc Search(SearchRequest) returns (SearchResponse) {\n" -- 2.40.0