From: Martin Probst Date: Tue, 6 Sep 2016 18:55:34 +0000 (+0000) Subject: clang-format: [JS] whitespace required between ! and as. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=faabfd1219acc01a4c26e31ed06e83b482129c57;p=clang clang-format: [JS] whitespace required between ! and as. Summary: Before: x!as string After: x! as string Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D24272 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@280731 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 0708593981..3b3521290b 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -2158,6 +2158,8 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, tok::r_square, tok::r_brace) || Left.Tok.isLiteral())) return false; + if (Left.is(tok::exclaim) && Right.is(Keywords.kw_as)) + return true; // "x! as string" } else if (Style.Language == FormatStyle::LK_Java) { if (Left.is(tok::r_square) && Right.is(tok::l_brace)) return true; diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp index 17d5cd58f1..569f065761 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/unittests/Format/FormatTestJS.cpp @@ -1236,6 +1236,7 @@ TEST_F(FormatTestJS, CastSyntax) { verifyFormat("x = x as [a, b];"); verifyFormat("x = x as {a: string};"); verifyFormat("x = x as (string);"); + verifyFormat("x = x! as (string);"); } TEST_F(FormatTestJS, TypeArguments) {