From: Martin Probst Date: Fri, 24 Nov 2017 17:04:40 +0000 (+0000) Subject: clang-format: [JS] space between ! assert and in. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fa6446753a59fb44b2cbb170f3d3c6688b492b66;p=clang clang-format: [JS] space between ! assert and in. Summary: Before: x = y!in z; After: x = y! in z; Reviewers: djasper Subscribers: klimek Differential Revision: https://reviews.llvm.org/D40433 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@318957 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 0e2e8a8374..1962ab2ab9 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -2433,8 +2433,9 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, return false; if (Right.is(TT_JsNonNullAssertion)) return false; - if (Left.is(TT_JsNonNullAssertion) && Right.is(Keywords.kw_as)) - return true; // "x! as string" + if (Left.is(TT_JsNonNullAssertion) && + Right.isOneOf(Keywords.kw_as, Keywords.kw_in)) + return true; // "x! as string", "x! in y" } 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 d9176599fb..b8c81d14f4 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/unittests/Format/FormatTestJS.cpp @@ -1908,6 +1908,7 @@ TEST_F(FormatTestJS, CastSyntax) { verifyFormat("x = x as {a: string};"); verifyFormat("x = x as (string);"); verifyFormat("x = x! as (string);"); + verifyFormat("x = y! in z;"); verifyFormat("var x = something.someFunction() as\n" " something;", getGoogleJSStyleWithColumns(40));