From: Daniel Jasper Date: Mon, 3 Nov 2014 02:35:14 +0000 (+0000) Subject: clang-format: [Java] Fix static generic methods. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=03bea9810856083ba2f5a8972fbcb7ee821a1b36;p=clang clang-format: [Java] Fix static generic methods. Before: public static ArrayList get() {} After: public static ArrayList get() {} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221122 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index bebd6cc18d..0b2b222094 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -1685,6 +1685,8 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, } 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. diff --git a/unittests/Format/FormatTestJava.cpp b/unittests/Format/FormatTestJava.cpp index 60111b19ed..a47bfcaab8 100644 --- a/unittests/Format/FormatTestJava.cpp +++ b/unittests/Format/FormatTestJava.cpp @@ -140,8 +140,9 @@ TEST_F(FormatTestJava, Generics) { verifyFormat("A.doSomething();"); verifyFormat("@Override\n" - "public Map getAll() {\n" - "}"); + "public Map getAll() {\n}"); + + verifyFormat("public static ArrayList get() {\n}"); } TEST_F(FormatTestJava, StringConcatenation) {