r225964 - clang-format: [Java] Don't let annotations confuse return type analysis.
Daniel Jasper
djasper at google.com
Wed Jan 14 02:00:20 PST 2015
Author: djasper
Date: Wed Jan 14 04:00:20 2015
New Revision: 225964
URL: http://llvm.org/viewvc/llvm-project?rev=225964&view=rev
Log:
clang-format: [Java] Don't let annotations confuse return type analysis.
Before:
@Test
ReturnType
doSomething(String aaaaaaaaaaaaa, String bbbbbbbbbbbbbbb) {}
After:
@Test
ReturnType doSomething(
String aaaaaaaaaaaaa, String bbbbbbbbbbbbbbb) {}
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=225964&r1=225963&r2=225964&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Jan 14 04:00:20 2015
@@ -900,6 +900,9 @@ private:
if (Tok.isNot(tok::identifier) || !Tok.Previous)
return false;
+ if (Tok.Previous->is(TT_LeadingJavaAnnotation))
+ return false;
+
// Skip "const" as it does not have an influence on whether this is a name.
FormatToken *PreviousNotConst = Tok.Previous;
while (PreviousNotConst && PreviousNotConst->is(tok::kw_const))
Modified: cfe/trunk/unittests/Format/FormatTestJava.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJava.cpp?rev=225964&r1=225963&r2=225964&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJava.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJava.cpp Wed Jan 14 04:00:20 2015
@@ -283,6 +283,10 @@ TEST_F(FormatTestJava, Annotations) {
" aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa)\n"
"int i;",
getStyleWithColumns(50));
+ verifyFormat("@Test\n"
+ "ReturnType doSomething(\n"
+ " String aaaaaaaaaaaaa, String bbbbbbbbbbbbbbb) {}",
+ getStyleWithColumns(60));
}
TEST_F(FormatTestJava, Generics) {
More information about the cfe-commits
mailing list