From 4e614a34eb2b9904174e5f935212443ec14eba88 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Thu, 20 Nov 2014 09:48:11 +0000 Subject: [PATCH] clang-format: [Java] Don't force break before generic type method. Before: Foo.bar() . baz(); After: Foo.bar() .baz(); Patch by Harry Terkelsen. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222423 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/TokenAnnotator.cpp | 1 + unittests/Format/FormatTestJava.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index f9da8c9230..1afdb19b29 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -878,6 +878,7 @@ private: if (PreviousNotConst->Type == TT_TemplateCloser) return PreviousNotConst && PreviousNotConst->MatchingParen && PreviousNotConst->MatchingParen->Previous && + PreviousNotConst->MatchingParen->Previous->isNot(tok::period) && PreviousNotConst->MatchingParen->Previous->isNot(tok::kw_template); if (PreviousNotConst->is(tok::r_paren) && PreviousNotConst->MatchingParen && diff --git a/unittests/Format/FormatTestJava.cpp b/unittests/Format/FormatTestJava.cpp index 5c9bf1a25f..94070f46a0 100644 --- a/unittests/Format/FormatTestJava.cpp +++ b/unittests/Format/FormatTestJava.cpp @@ -234,6 +234,13 @@ TEST_F(FormatTestJava, Generics) { verifyFormat("private Foo[] foos;"); verifyFormat("Foo[] foos = this.foos;"); + + verifyFormat( + "SomeLoooooooooooooooooooooongType name =\n" + " SomeType.foo(someArgument)\n" + " .method()\n" + " .aaaaaaaaaaaaaaaaaaa()\n" + " .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa();"); } TEST_F(FormatTestJava, StringConcatenation) { -- 2.40.0