r253667 - clang-format: [Proto] Support extending message.
Daniel Jasper via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 20 06:32:54 PST 2015
Author: djasper
Date: Fri Nov 20 08:32:54 2015
New Revision: 253667
URL: http://llvm.org/viewvc/llvm-project?rev=253667&view=rev
Log:
clang-format: [Proto] Support extending message.
Before:
extend.foo.Bar {
}
After:
extend .foo.Bar {
}
Modified:
cfe/trunk/lib/Format/FormatToken.h
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestProto.cpp
Modified: cfe/trunk/lib/Format/FormatToken.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=253667&r1=253666&r2=253667&view=diff
==============================================================================
--- cfe/trunk/lib/Format/FormatToken.h (original)
+++ cfe/trunk/lib/Format/FormatToken.h Fri Nov 20 08:32:54 2015
@@ -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;
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=253667&r1=253666&r2=253667&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Nov 20 08:32:54 2015
@@ -1949,7 +1949,7 @@ bool TokenAnnotator::spaceRequiredBefore
} 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))
Modified: cfe/trunk/unittests/Format/FormatTestProto.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestProto.cpp?rev=253667&r1=253666&r2=253667&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestProto.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestProto.cpp Fri Nov 20 08:32:54 2015
@@ -162,5 +162,10 @@ TEST_F(FormatTestProto, FormatsService)
"};");
}
+TEST_F(FormatTestProto, ExtendingMessage) {
+ verifyFormat("extend .foo.Bar {\n"
+ "}");
+}
+
} // end namespace tooling
} // end namespace clang
More information about the cfe-commits
mailing list