clang-format: [Java] Improve generic return type formatting.

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

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

llvm-svn: 221979
This commit is contained in:
Daniel Jasper 2014-11-14 09:05:32 +00:00
parent 30a2406e65
commit 09f6abe8d8
2 changed files with 3 additions and 1 deletions

View File

@ -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())

View File

@ -205,6 +205,7 @@ TEST_F(FormatTestJava, Generics) {
verifyFormat("@Override\n"
"public Map<String, ?> getAll() {\n}");
verifyFormat("public <R> ArrayList<R> get() {\n}");
verifyFormat("public static <R> ArrayList<R> get() {\n}");
verifyFormat("<T extends B> T getInstance(Class<T> type);");
verifyFormat("Function<F, ? extends T> function;");