r225962 - clang-format: [Java] Don't get confused by leading annotations.
Daniel Jasper
djasper at google.com
Wed Jan 14 01:47:58 PST 2015
Author: djasper
Date: Wed Jan 14 03:47:57 2015
New Revision: 225962
URL: http://llvm.org/viewvc/llvm-project?rev=225962&view=rev
Log:
clang-format: [Java] Don't get confused by leading annotations.
Before:
@Test(a)
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaa);
After:
@Test(a)
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =
aaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa);
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=225962&r1=225961&r2=225962&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Jan 14 03:47:57 2015
@@ -458,7 +458,8 @@ private:
return false;
if (Line.MustBeDeclaration && Contexts.size() == 1 &&
!Contexts.back().IsExpression && Line.First->isNot(TT_ObjCProperty) &&
- (!Tok->Previous || Tok->Previous->isNot(tok::kw_decltype)))
+ (!Tok->Previous ||
+ !Tok->Previous->isOneOf(tok::kw_decltype, TT_LeadingJavaAnnotation)))
Line.MightBeFunctionDecl = true;
break;
case tok::l_square:
Modified: cfe/trunk/unittests/Format/FormatTestJava.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJava.cpp?rev=225962&r1=225961&r2=225962&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJava.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJava.cpp Wed Jan 14 03:47:57 2015
@@ -276,6 +276,9 @@ TEST_F(FormatTestJava, Annotations) {
"DataLoader loooooooooooooooooooooooader =\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;",
getStyleWithColumns(60));
+ verifyFormat("@Test(a)\n"
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa);");
}
TEST_F(FormatTestJava, Generics) {
More information about the cfe-commits
mailing list