clang-format: [JS] whitespace required between ! and as.
authorMartin Probst <martin@probst.io>
Tue, 6 Sep 2016 18:55:34 +0000 (18:55 +0000)
committerMartin Probst <martin@probst.io>
Tue, 6 Sep 2016 18:55:34 +0000 (18:55 +0000)
Summary:
Before:
    x!as string
After:
    x! as string

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 280731

clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTestJS.cpp

index 0708593..3b35212 100644 (file)
@@ -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;
index 17d5cd5..569f065 100644 (file)
@@ -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) {