]> granicus.if.org Git - clang/commitdiff
clang-format: [Java] Further improve generics formatting.
authorDaniel Jasper <djasper@google.com>
Fri, 14 Nov 2014 17:30:15 +0000 (17:30 +0000)
committerDaniel Jasper <djasper@google.com>
Fri, 14 Nov 2014 17:30:15 +0000 (17:30 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222011 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTestJava.cpp

index 104eb1d7afb89d77c03bbb8d31ac247218a17da8..74fb0f7a727484cfbc97d6b636c7e78b9e32625c 100644 (file)
@@ -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;
   }
index 6523c86f5260a8641751a64c82bfeb4b1013373a..eecac0f3fcd05c9e2b01dfa437c638274bcaceb7 100644 (file)
@@ -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;");