Index: lib/Format/FormatToken.h =================================================================== --- lib/Format/FormatToken.h +++ lib/Format/FormatToken.h @@ -543,7 +543,9 @@ kw_function = &IdentTable.get("function"); kw_var = &IdentTable.get("var"); + kw_abstract = &IdentTable.get("abstract"); kw_extends = &IdentTable.get("extends"); + kw_final = &IdentTable.get("final"); kw_implements = &IdentTable.get("implements"); kw_interface = &IdentTable.get("interface"); kw_synchronized = &IdentTable.get("synchronized"); @@ -566,7 +568,9 @@ IdentifierInfo *kw_var; // Java keywords. + IdentifierInfo *kw_abstract; IdentifierInfo *kw_extends; + IdentifierInfo *kw_final; IdentifierInfo *kw_implements; IdentifierInfo *kw_interface; IdentifierInfo *kw_synchronized; Index: lib/Format/TokenAnnotator.cpp =================================================================== --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -1703,8 +1703,9 @@ } 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, tok::kw_private, - tok::kw_protected) && + if ((Left.isOneOf(tok::kw_static, tok::kw_public, tok::kw_private, + tok::kw_protected) || + Left.isOneOf(Keywords.kw_final, Keywords.kw_abstract)) && Right.Type == TT_TemplateOpener) return true; } Index: unittests/Format/FormatTestJava.cpp =================================================================== --- unittests/Format/FormatTestJava.cpp +++ unittests/Format/FormatTestJava.cpp @@ -229,6 +229,8 @@ verifyFormat("protected ArrayList get() {\n}"); verifyFormat("private ArrayList get() {\n}"); verifyFormat("public static ArrayList get() {\n}"); + verifyFormat("public final Foo foo() {\n}"); + verifyFormat("public abstract Foo foo();"); verifyFormat(" T getInstance(Class type);"); verifyFormat("Function function;");