diff options
| author | Daniel Jasper <djasper@google.com> | 2015-10-29 19:05:20 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2015-10-29 19:05:20 +0000 |
| commit | b488a74f994b874c2134dfd7c9c4a886fb7fe964 (patch) | |
| tree | ffdf66b3690806a7b12f2304755584cc2d51810e /clang | |
| parent | 204aa1d9806425e4a6debdd75390acea1a655e77 (diff) | |
| download | bcm5719-llvm-b488a74f994b874c2134dfd7c9c4a886fb7fe964.tar.gz bcm5719-llvm-b488a74f994b874c2134dfd7c9c4a886fb7fe964.zip | |
clang-format: [JS] Add goog.setTestOnly to the list of stuff that
is import-statement-like and shouldn't be wrapped.
llvm-svn: 251643
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 7 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTestJS.cpp | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index d26f15b8be8..b44a34115ff 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/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/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index d26f96d6e4c..b491cd58659 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/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( |

