Author: Nico Weber Date: 2020-01-03T12:11:44-05:00 New Revision: ba3484c051b62a662c555200f4a03b2e8df8e094
URL: https://github.com/llvm/llvm-project/commit/ba3484c051b62a662c555200f4a03b2e8df8e094 DIFF: https://github.com/llvm/llvm-project/commit/ba3484c051b62a662c555200f4a03b2e8df8e094.diff LOG: [clang-format/java] format multiple qualified annotations on one declaration better Before: class Foo { @CommandLineFlags .Add @Features.foo public void test() {} } Now: class Foo { @Features.foo @CommandLineFlags.Add public void test() { } } See also https://crbug.com/1034115 Added: Modified: clang/lib/Format/FormatToken.h clang/unittests/Format/FormatTestJava.cpp Removed: ################################################################################ diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h index 39498280fb6d..e9cd327754ef 100644 --- a/clang/lib/Format/FormatToken.h +++ b/clang/lib/Format/FormatToken.h @@ -407,7 +407,7 @@ struct FormatToken { bool isMemberAccess() const { return isOneOf(tok::arrow, tok::period, tok::arrowstar) && !isOneOf(TT_DesignatedInitializerPeriod, TT_TrailingReturnArrow, - TT_LambdaArrow); + TT_LambdaArrow, TT_LeadingJavaAnnotation); } bool isUnaryOperator() const { diff --git a/clang/unittests/Format/FormatTestJava.cpp b/clang/unittests/Format/FormatTestJava.cpp index a4936e0e1ccc..5e73e4b4ea4e 100644 --- a/clang/unittests/Format/FormatTestJava.cpp +++ b/clang/unittests/Format/FormatTestJava.cpp @@ -335,6 +335,14 @@ TEST_F(FormatTestJava, Annotations) { verifyFormat("@Annotation(\"Some\"\n" " + \" text\")\n" "List<Integer> list;"); + + verifyFormat( + "@Test\n" + "@Feature({\"Android-TabSwitcher\"})\n" + "@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})\n" + "@Features.EnableFeatures({FEATURE})\n" + "public void test(@Foo.bar(\"baz\") @Quux.Qoob int theFirstParaaaaam,\n" + " @Foo.bar(\"baz\") @Quux.Qoob int theSecondParaaaaaaaaaaaaaaaam) {}"); } TEST_F(FormatTestJava, Generics) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits