From: Daniel Jasper Date: Fri, 14 Nov 2014 17:30:15 +0000 (+0000) Subject: clang-format: [Java] Further improve generics formatting. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1eb487737163e1dd201596f2d7856094c8e6882b;p=clang clang-format: [Java] Further improve generics formatting. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222011 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 104eb1d7af..74fb0f7a72 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -1696,7 +1696,8 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, } else if (Style.Language == FormatStyle::LK_Java) { if (Left.is(Keywords.kw_synchronized) && Right.is(tok::l_paren)) return Style.SpaceBeforeParens != FormatStyle::SBPO_Never; - if (Left.isOneOf(tok::kw_static, tok::kw_public) && + if (Left.isOneOf(tok::kw_static, tok::kw_public, tok::kw_private, + tok::kw_protected) && Right.Type == TT_TemplateOpener) return true; } diff --git a/unittests/Format/FormatTestJava.cpp b/unittests/Format/FormatTestJava.cpp index 6523c86f52..eecac0f3fc 100644 --- a/unittests/Format/FormatTestJava.cpp +++ b/unittests/Format/FormatTestJava.cpp @@ -212,6 +212,8 @@ TEST_F(FormatTestJava, Generics) { "public Map getAll() {\n}"); verifyFormat("public ArrayList get() {\n}"); + verifyFormat("protected ArrayList get() {\n}"); + verifyFormat("private ArrayList get() {\n}"); verifyFormat("public static ArrayList get() {\n}"); verifyFormat(" T getInstance(Class type);"); verifyFormat("Function function;");