clang-format: [Java] Improve annotation handling.

Before:
@SuppressWarnings(
    value = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") public static int iiiiiiiiiiiiiiiiiiiiiiii;

After:
  @SuppressWarnings(value = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
  public static int iiiiiiiiiiiiiiiiiiiiiiii;

llvm-svn: 220284
This commit is contained in:
Daniel Jasper 2014-10-21 10:58:14 +00:00
parent 171eb8dbeb
commit fd68191db4
2 changed files with 4 additions and 0 deletions

View File

@ -1817,6 +1817,8 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
return false; return false;
if (Left.Tok.getObjCKeywordID() == tok::objc_interface) if (Left.Tok.getObjCKeywordID() == tok::objc_interface)
return false; return false;
if (Left.Type == TT_JavaAnnotation)
return true;
if (Right.Type == TT_StartOfName || if (Right.Type == TT_StartOfName ||
Right.Type == TT_FunctionDeclarationName || Right.is(tok::kw_operator)) Right.Type == TT_FunctionDeclarationName || Right.is(tok::kw_operator))
return true; return true;

View File

@ -82,6 +82,8 @@ TEST_F(FormatTestJava, Annotations) {
"});"); "});");
verifyFormat("@Partial @Mock DataLoader loader;"); verifyFormat("@Partial @Mock DataLoader loader;");
verifyFormat("@SuppressWarnings(value = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\")\n"
"public static int iiiiiiiiiiiiiiiiiiiiiiii;");
} }
TEST_F(FormatTestJava, Generics) { TEST_F(FormatTestJava, Generics) {