From 4b081fab9a951c7d0d162e4b6f20aa5a0722e5ae Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Tue, 21 Oct 2014 11:17:56 +0000 Subject: [PATCH] clang-format: [Java] Fix formatting of multiple annotations. Before: @SuppressWarnings(value = "unchecked") @Author(name = "abc") public void doSomething() { } After: @SuppressWarnings(value = "unchecked") @Author(name = "abc") public void doSomething() { } git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220286 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/TokenAnnotator.cpp | 3 ++- unittests/Format/FormatTestJava.cpp | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 4b39b50735..db0e931659 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -827,7 +827,8 @@ private: PreviousNoComment->isOneOf(tok::comma, tok::l_brace)) Current.Type = TT_DesignatedInitializerPeriod; } else if (Current.isOneOf(tok::identifier, tok::kw_const) && - Current.Previous && Current.Previous->isNot(tok::equal) && + Current.Previous && + !Current.Previous->isOneOf(tok::equal, tok::at) && Line.MightBeFunctionDecl && Contexts.size() == 1) { // Line.MightBeFunctionDecl can only be true after the parentheses of a // function declaration have been found. diff --git a/unittests/Format/FormatTestJava.cpp b/unittests/Format/FormatTestJava.cpp index f7d85fc4a0..d38a8070bd 100644 --- a/unittests/Format/FormatTestJava.cpp +++ b/unittests/Format/FormatTestJava.cpp @@ -74,6 +74,9 @@ TEST_F(FormatTestJava, Annotations) { verifyFormat("@SuppressWarnings(value = \"unchecked\")\n" "public void doSomething() {\n}"); + verifyFormat("@SuppressWarnings(value = \"unchecked\")\n" + "@Author(name = \"abc\")\n" + "public void doSomething() {\n}"); verifyFormat("DoSomething(new A() {\n" " @Override\n" -- 2.40.0