From: Daniel Jasper Date: Fri, 20 Nov 2015 14:32:54 +0000 (+0000) Subject: clang-format: [Proto] Support extending message. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c48bd86a1862bf8ae5efcbb2b0681d05c1936d8e;p=clang clang-format: [Proto] Support extending message. Before: extend.foo.Bar { } After: extend .foo.Bar { } git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253667 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/FormatToken.h b/lib/Format/FormatToken.h index 002ff25bfa..4988520599 100644 --- a/lib/Format/FormatToken.h +++ b/lib/Format/FormatToken.h @@ -553,6 +553,7 @@ struct AdditionalKeywords { kw_mark = &IdentTable.get("mark"); + kw_extend = &IdentTable.get("extend"); kw_option = &IdentTable.get("option"); kw_optional = &IdentTable.get("optional"); kw_repeated = &IdentTable.get("repeated"); @@ -597,6 +598,7 @@ struct AdditionalKeywords { IdentifierInfo *kw_mark; // Proto keywords. + IdentifierInfo *kw_extend; IdentifierInfo *kw_option; IdentifierInfo *kw_optional; IdentifierInfo *kw_repeated; diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 8f08828b5f..70ff7d8b9e 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -1949,7 +1949,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, } else if (Style.Language == FormatStyle::LK_Proto) { if (Right.is(tok::period) && Left.isOneOf(Keywords.kw_optional, Keywords.kw_required, - Keywords.kw_repeated)) + Keywords.kw_repeated, Keywords.kw_extend)) return true; if (Right.is(tok::l_paren) && Left.isOneOf(Keywords.kw_returns, Keywords.kw_option)) diff --git a/unittests/Format/FormatTestProto.cpp b/unittests/Format/FormatTestProto.cpp index 0dadd3b673..cd2c0c8aa4 100644 --- a/unittests/Format/FormatTestProto.cpp +++ b/unittests/Format/FormatTestProto.cpp @@ -162,5 +162,10 @@ TEST_F(FormatTestProto, FormatsService) { "};"); } +TEST_F(FormatTestProto, ExtendingMessage) { + verifyFormat("extend .foo.Bar {\n" + "}"); +} + } // end namespace tooling } // end namespace clang