From: Martin Probst Date: Mon, 7 Jan 2019 13:12:50 +0000 (+0000) Subject: clang-format: [JS] support goog.requireType. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=84ee269c66965015f9e39a4b1005c81d1b174677;p=clang clang-format: [JS] support goog.requireType. 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 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index a04f2e672b..24c2f998c3 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -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); } diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp index a14724f85e..67b99ba146 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/unittests/Format/FormatTestJS.cpp @@ -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));