]> granicus.if.org Git - clang/commitdiff
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@280731 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 0708593981021c4d2a02a89a2dcb7a3e180551a7..3b3521290bfc966e87802900db4dc53108cd736a 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 17d5cd58f1d0184b95b2ba9dcdb96d05a485eab2..569f06576174f49b25b8b655d9b777a04748f5af 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) {