r221122 - clang-format: [Java] Fix static generic methods.

Daniel Jasper djasper at google.com
Sun Nov 2 18:35:14 PST 2014


Author: djasper
Date: Sun Nov  2 20:35:14 2014
New Revision: 221122

URL: http://llvm.org/viewvc/llvm-project?rev=221122&view=rev
Log:
clang-format: [Java] Fix static generic methods.

Before:
  public static<R> ArrayList<R> get() {}

After:
  public static <R> ArrayList<R> get() {}

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=221122&r1=221121&r2=221122&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Sun Nov  2 20:35:14 2014
@@ -1685,6 +1685,8 @@ bool TokenAnnotator::spaceRequiredBefore
   } else if (Style.Language == FormatStyle::LK_Java) {
     if (Left.TokenText == "synchronized" && Right.is(tok::l_paren))
       return Style.SpaceBeforeParens != FormatStyle::SBPO_Never;
+    if (Left.is(tok::kw_static) && Right.Type == TT_TemplateOpener)
+      return true;
   }
   if (Right.Tok.getIdentifierInfo() && Left.Tok.getIdentifierInfo())
     return true; // Never ever merge two identifiers.

Modified: cfe/trunk/unittests/Format/FormatTestJava.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJava.cpp?rev=221122&r1=221121&r2=221122&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJava.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJava.cpp Sun Nov  2 20:35:14 2014
@@ -140,8 +140,9 @@ TEST_F(FormatTestJava, Generics) {
   verifyFormat("A.<B>doSomething();");
 
   verifyFormat("@Override\n"
-               "public Map<String, ?> getAll() {\n"
-               "}");
+               "public Map<String, ?> getAll() {\n}");
+
+  verifyFormat("public static <R> ArrayList<R> get() {\n}");
 }
 
 TEST_F(FormatTestJava, StringConcatenation) {





More information about the cfe-commits mailing list