r222011 - clang-format: [Java] Further improve generics formatting.
Daniel Jasper
djasper at google.com
Fri Nov 14 09:30:15 PST 2014
Author: djasper
Date: Fri Nov 14 11:30:15 2014
New Revision: 222011
URL: http://llvm.org/viewvc/llvm-project?rev=222011&view=rev
Log:
clang-format: [Java] Further improve generics formatting.
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJava.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=222011&r1=222010&r2=222011&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Nov 14 11:30:15 2014
@@ -1696,7 +1696,8 @@ bool TokenAnnotator::spaceRequiredBefore
} 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;
}
Modified: cfe/trunk/unittests/Format/FormatTestJava.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJava.cpp?rev=222011&r1=222010&r2=222011&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJava.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJava.cpp Fri Nov 14 11:30:15 2014
@@ -212,6 +212,8 @@ TEST_F(FormatTestJava, Generics) {
"public Map<String, ?> getAll() {\n}");
verifyFormat("public <R> ArrayList<R> get() {\n}");
+ verifyFormat("protected <R> ArrayList<R> get() {\n}");
+ verifyFormat("private <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;");
More information about the cfe-commits
mailing list