From ffe568b91fc3f8464483e4f1d808686276f40e4d Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Fri, 14 Nov 2014 09:05:32 +0000 Subject: [PATCH] clang-format: [Java] Improve generic return type formatting. Before: public ArrayList get() { After: public ArrayList get() { git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221979 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/TokenAnnotator.cpp | 3 ++- unittests/Format/FormatTestJava.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index f926beb106..bce1d64166 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -1684,7 +1684,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.is(tok::kw_static) && Right.Type == TT_TemplateOpener) + if (Left.isOneOf(tok::kw_static, tok::kw_public) && + Right.Type == TT_TemplateOpener) return true; } if (Right.Tok.getIdentifierInfo() && Left.Tok.getIdentifierInfo()) diff --git a/unittests/Format/FormatTestJava.cpp b/unittests/Format/FormatTestJava.cpp index e8e35c85ef..3799003b77 100644 --- a/unittests/Format/FormatTestJava.cpp +++ b/unittests/Format/FormatTestJava.cpp @@ -205,6 +205,7 @@ TEST_F(FormatTestJava, Generics) { verifyFormat("@Override\n" "public Map getAll() {\n}"); + verifyFormat("public ArrayList get() {\n}"); verifyFormat("public static ArrayList get() {\n}"); verifyFormat(" T getInstance(Class type);"); verifyFormat("Function function;"); -- 2.40.0