]> granicus.if.org Git - clang/commitdiff
clang-format: [JS] support goog.requireType.
authorMartin Probst <martin@probst.io>
Mon, 7 Jan 2019 13:12:50 +0000 (13:12 +0000)
committerMartin Probst <martin@probst.io>
Mon, 7 Jan 2019 13:12:50 +0000 (13:12 +0000)
Summary:
It's a new primitive for importing symbols, and should be treated like
the (previously handled) `goog.require` and `goog.forwardDeclare`.

Reviewers: krasimir

Subscribers: cfe-commits

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

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

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

index a04f2e672b45a64b9cbdce50c2ffc8cc07c62c56..24c2f998c388aa3c33b4fe31ace54dba706a665d 100644 (file)
@@ -1123,6 +1123,7 @@ private:
            (Tok.Next->Next->TokenText == "module" ||
             Tok.Next->Next->TokenText == "provide" ||
             Tok.Next->Next->TokenText == "require" ||
+            Tok.Next->Next->TokenText == "requireType" ||
             Tok.Next->Next->TokenText == "forwardDeclare") &&
            Tok.Next->Next->Next && Tok.Next->Next->Next->is(tok::l_paren);
   }
index a14724f85ebe09beab7b3c9f086c986ba299d620..67b99ba146dadead2e36541f76daf8cb5cce5dcd 100644 (file)
@@ -600,6 +600,8 @@ TEST_F(FormatTestJS, GoogModules) {
                getGoogleJSStyleWithColumns(40));
   verifyFormat("var long = goog.require('this.is.really.absurdly.long');",
                getGoogleJSStyleWithColumns(40));
+  verifyFormat("const X = goog.requireType('this.is.really.absurdly.long');",
+               getGoogleJSStyleWithColumns(40));
   verifyFormat("goog.forwardDeclare('this.is.really.absurdly.long');",
                getGoogleJSStyleWithColumns(40));