clang-format: [JS] Fix incorrect space when "as" is used as identifier.
authorDaniel Jasper <djasper@google.com>
Tue, 1 Nov 2016 06:23:10 +0000 (06:23 +0000)
committerDaniel Jasper <djasper@google.com>
Tue, 1 Nov 2016 06:23:10 +0000 (06:23 +0000)
Before:
  aaaaa.as ();

After:
  aaaaa.as();

llvm-svn: 285672

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

index 129fe84..1a3faad 100644 (file)
@@ -2160,7 +2160,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
                      Keywords.kw_of, tok::kw_const) &&
         (!Left.Previous || !Left.Previous->is(tok::period)))
       return true;
-    if (Left.is(tok::kw_for) && Left.Previous &&
+    if (Left.isOneOf(tok::kw_for, Keywords.kw_as) && Left.Previous &&
         Left.Previous->is(tok::period) && Right.is(tok::l_paren))
       return false;
     if (Left.is(Keywords.kw_as) &&
index 846abaf..f4b5059 100644 (file)
@@ -136,6 +136,7 @@ TEST_F(FormatTestJS, ReservedWords) {
   verifyFormat("x.let() = 1;");
   verifyFormat("x.var() = 1;");
   verifyFormat("x.for() = 1;");
+  verifyFormat("x.as() = 1;");
   verifyFormat("x = {\n"
                "  a: 12,\n"
                "  interface: 1,\n"