From: Daniel Jasper Date: Thu, 29 Oct 2015 19:05:20 +0000 (+0000) Subject: clang-format: [JS] Add goog.setTestOnly to the list of stuff that X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0bc484328975265a0e3110ce0d601eed923bb78f;p=clang clang-format: [JS] Add goog.setTestOnly to the list of stuff that is import-statement-like and shouldn't be wrapped. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@251643 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index d26f15b8be..b44a34115f 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -727,7 +727,7 @@ public: while (CurrentToken) { if (CurrentToken->is(tok::kw_virtual)) KeywordVirtualFound = true; - if (IsImportStatement(*CurrentToken)) + if (isImportStatement(*CurrentToken)) ImportStatement = true; if (!consumeToken()) return LT_Invalid; @@ -748,14 +748,15 @@ public: } private: - bool IsImportStatement(const FormatToken &Tok) { + bool isImportStatement(const FormatToken &Tok) { // FIXME: Closure-library specific stuff should not be hard-coded but be // configurable. return Style.Language == FormatStyle::LK_JavaScript && Tok.TokenText == "goog" && Tok.Next && Tok.Next->is(tok::period) && Tok.Next->Next && (Tok.Next->Next->TokenText == "module" || + Tok.Next->Next->TokenText == "provide" || Tok.Next->Next->TokenText == "require" || - Tok.Next->Next->TokenText == "provide") && + Tok.Next->Next->TokenText == "setTestOnly") && 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 d26f96d6e4..b491cd5865 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/unittests/Format/FormatTestJS.cpp @@ -252,6 +252,8 @@ TEST_F(FormatTestJS, GoogModules) { getGoogleJSStyleWithColumns(40)); verifyFormat("var long = goog.require('this.is.really.absurdly.long');", getGoogleJSStyleWithColumns(40)); + verifyFormat("goog.setTestOnly('this.is.really.absurdly.long');", + getGoogleJSStyleWithColumns(40)); // These should be wrapped normally. verifyFormat(