From 572143c0e038397c63b32e39d4e1975c281bd27c Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Wed, 26 Nov 2014 12:31:19 +0000 Subject: [PATCH] clang-format: [Java] Improve formatting of throws declarations. Before: public void doSoooooooooo() throws LoooooooooongException, LooooooooooongException {} After: public void doSoooooooooo() throws LoooooooooongException, LooooooooooongException {} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222829 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/TokenAnnotator.cpp | 5 +++-- unittests/Format/FormatTestJava.cpp | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 2e3e2dd612..ccaac1bb28 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -1200,7 +1200,8 @@ private: else if (Current->isOneOf(tok::period, tok::arrow)) return PrecedenceArrowAndPeriod; else if (Style.Language == FormatStyle::LK_Java && - Current->isOneOf(Keywords.kw_extends, Keywords.kw_implements)) + Current->isOneOf(Keywords.kw_extends, Keywords.kw_implements, + Keywords.kw_throws)) return 0; } return -1; @@ -1470,7 +1471,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line, if (Style.Language == FormatStyle::LK_Java) { if (Left.is(TT_LeadingJavaAnnotation)) return 1; - if (Right.is(Keywords.kw_extends)) + if (Right.isOneOf(Keywords.kw_extends, Keywords.kw_throws)) return 1; if (Right.is(Keywords.kw_implements)) return 2; diff --git a/unittests/Format/FormatTestJava.cpp b/unittests/Format/FormatTestJava.cpp index 674c13b516..b99dec73ee 100644 --- a/unittests/Format/FormatTestJava.cpp +++ b/unittests/Format/FormatTestJava.cpp @@ -202,6 +202,8 @@ TEST_F(FormatTestJava, ArrayInitializers) { TEST_F(FormatTestJava, ThrowsDeclarations) { verifyFormat("public void doSooooooooooooooooooooooooooomething()\n" " throws LooooooooooooooooooooooooooooongException {}"); + verifyFormat("public void doSooooooooooooooooooooooooooomething()\n" + " throws LoooooooooongException, LooooooooooongException {}"); } TEST_F(FormatTestJava, Annotations) { -- 2.40.0