r220286 - clang-format: [Java] Fix formatting of multiple annotations.
Daniel Jasper
djasper at google.com
Tue Oct 21 04:17:56 PDT 2014
Author: djasper
Date: Tue Oct 21 06:17:56 2014
New Revision: 220286
URL: http://llvm.org/viewvc/llvm-project?rev=220286&view=rev
Log:
clang-format: [Java] Fix formatting of multiple annotations.
Before:
@SuppressWarnings(value = "unchecked")
@Author(name = "abc") public void doSomething() {
}
After:
@SuppressWarnings(value = "unchecked")
@Author(name = "abc")
public void doSomething() {
}
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJava.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=220286&r1=220285&r2=220286&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Oct 21 06:17:56 2014
@@ -827,7 +827,8 @@ private:
PreviousNoComment->isOneOf(tok::comma, tok::l_brace))
Current.Type = TT_DesignatedInitializerPeriod;
} else if (Current.isOneOf(tok::identifier, tok::kw_const) &&
- Current.Previous && Current.Previous->isNot(tok::equal) &&
+ Current.Previous &&
+ !Current.Previous->isOneOf(tok::equal, tok::at) &&
Line.MightBeFunctionDecl && Contexts.size() == 1) {
// Line.MightBeFunctionDecl can only be true after the parentheses of a
// function declaration have been found.
Modified: cfe/trunk/unittests/Format/FormatTestJava.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJava.cpp?rev=220286&r1=220285&r2=220286&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJava.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJava.cpp Tue Oct 21 06:17:56 2014
@@ -74,6 +74,9 @@ TEST_F(FormatTestJava, Annotations) {
verifyFormat("@SuppressWarnings(value = \"unchecked\")\n"
"public void doSomething() {\n}");
+ verifyFormat("@SuppressWarnings(value = \"unchecked\")\n"
+ "@Author(name = \"abc\")\n"
+ "public void doSomething() {\n}");
verifyFormat("DoSomething(new A() {\n"
" @Override\n"
More information about the cfe-commits
mailing list