]> granicus.if.org Git - clang/commitdiff
clang-format: [JS] Add goog.setTestOnly to the list of stuff that
authorDaniel Jasper <djasper@google.com>
Thu, 29 Oct 2015 19:05:20 +0000 (19:05 +0000)
committerDaniel Jasper <djasper@google.com>
Thu, 29 Oct 2015 19:05:20 +0000 (19:05 +0000)
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

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

index d26f15b8be84f67c7c4bbee34ae07f51588cebd8..b44a34115ffaa3577f25a9b065e54a53a75444d4 100644 (file)
@@ -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);
   }
 
index d26f96d6e4cc121ad1aec6461423d63e7aac3418..b491cd5865935da1c923e68c0c721e6f9e3669d8 100644 (file)
@@ -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(