Skip to content

Commit

Permalink
clang-format: [JS] space between ! assert and in.
Browse files Browse the repository at this point in the history
Summary:
Before:
    x = y!in z;
After:
    x = y! in z;

Reviewers: djasper

Subscribers: klimek

Differential Revision: https://reviews.llvm.org/D40433

llvm-svn: 318957
  • Loading branch information
mprobst committed Nov 24, 2017
1 parent 230f453 commit a255511
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions clang/lib/Format/TokenAnnotator.cpp
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions clang/unittests/Format/FormatTestJS.cpp
Expand Up @@ -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));
Expand Down

0 comments on commit a255511

Please sign in to comment.