From 92ed6b0f9194caa68485a6fc901113fb7c21e238 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Mon, 25 Sep 2017 22:42:49 +0000 Subject: [PATCH] clang-format/java: Always put space after `assert` keyword. Previously, it was missing if the expression after the assert started with a (. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314172 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/TokenAnnotator.cpp | 2 ++ unittests/Format/FormatTestJava.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 1b04697857..1c6f6bba75 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -2185,6 +2185,8 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, const FormatToken &Right) { if (Left.is(tok::kw_return) && Right.isNot(tok::semi)) return true; + if (Left.is(Keywords.kw_assert) && Style.Language == FormatStyle::LK_Java) + return true; if (Style.ObjCSpaceAfterProperty && Line.Type == LT_ObjCProperty && Left.Tok.getObjCKeywordID() == tok::objc_property) return true; diff --git a/unittests/Format/FormatTestJava.cpp b/unittests/Format/FormatTestJava.cpp index 335c944f68..408fdaa85a 100644 --- a/unittests/Format/FormatTestJava.cpp +++ b/unittests/Format/FormatTestJava.cpp @@ -412,6 +412,7 @@ TEST_F(FormatTestJava, SynchronizedKeyword) { TEST_F(FormatTestJava, AssertKeyword) { verifyFormat("assert a && b;"); + verifyFormat("assert (a && b);"); } TEST_F(FormatTestJava, PackageDeclarations) { -- 2.40.0