clang-format: [JS] Make Closure module detection more narrow.

Before:
  var MyLongClassName = goog.module.get('my.long.module.name.followedBy.MyLongClassName');

After:
  var MyLongClassName =
      goog.module.get('my.long.module.name.followedBy.MyLongClassName');

llvm-svn: 222888
This commit is contained in:
Daniel Jasper 2014-11-27 14:46:03 +00:00
parent aa2b9278fe
commit 53c38f4e79
2 changed files with 7 additions and 1 deletions

View File

@ -661,7 +661,8 @@ private:
Tok.TokenText == "goog" && Tok.Next && Tok.Next->is(tok::period) &&
Tok.Next->Next && (Tok.Next->Next->TokenText == "module" ||
Tok.Next->Next->TokenText == "require" ||
Tok.Next->Next->TokenText == "provide");
Tok.Next->Next->TokenText == "provide") &&
Tok.Next->Next->Next && Tok.Next->Next->Next->is(tok::l_paren);
}
void resetTokenMetadata(FormatToken *Token) {

View File

@ -167,6 +167,11 @@ TEST_F(FormatTestJS, GoogModules) {
getGoogleJSStyleWithColumns(40));
verifyFormat("var long = goog.require('this.is.really.absurdly.long');",
getGoogleJSStyleWithColumns(40));
// These should be wrapped normally.
verifyFormat(
"var MyLongClassName =\n"
" goog.module.get('my.long.module.name.followedBy.MyLongClassName');");
}
TEST_F(FormatTestJS, FormatsFreestandingFunctions) {