r199672 - clang-format: Properly format custom options in protocol buffer definitions.
Daniel Jasper
djasper at google.com
Mon Jan 20 08:47:23 PST 2014
Author: djasper
Date: Mon Jan 20 10:47:22 2014
New Revision: 199672
URL: http://llvm.org/viewvc/llvm-project?rev=199672&view=rev
Log:
clang-format: Properly format custom options in protocol buffer definitions.
Before:
option(my_option) = "abc";
After:
option (my_option) = "abc";
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestProto.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=199672&r1=199671&r2=199672&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Jan 20 10:47:22 2014
@@ -1254,7 +1254,8 @@ bool TokenAnnotator::spaceRequiredBetwee
const FormatToken &Left,
const FormatToken &Right) {
if (Style.Language == FormatStyle::LK_Proto) {
- if (Right.is(tok::l_paren) && Left.TokenText == "returns")
+ if (Right.is(tok::l_paren) &&
+ (Left.TokenText == "returns" || Left.TokenText == "option"))
return true;
}
if (Right.is(tok::hashhash))
Modified: cfe/trunk/unittests/Format/FormatTestProto.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestProto.cpp?rev=199672&r1=199671&r2=199672&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestProto.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestProto.cpp Mon Jan 20 10:47:22 2014
@@ -68,5 +68,10 @@ TEST_F(FormatTestProto, MessageFieldAttr
" [default = REALLY_REALLY_LONG_CONSTANT_VALUE];");
}
+TEST_F(FormatTestProto, FormatsOptions) {
+ verifyFormat("option java_package = \"my.test.package\";");
+ verifyFormat("option (my_custom_option) = \"abc\";");
+}
+
} // end namespace tooling
} // end namespace clang
More information about the cfe-commits
mailing list