[PATCH] D32989: Don't indent JavaScript IIFEs

2017-05-09 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rL302580: clang-format: [JS] Don't indent JavaScript IIFEs. (authored by mprobst). Changed prior to commit: https://reviews.llvm.org/D32989?vs=98332=98344#toc Repository: rL LLVM

[PATCH] D32989: Don't indent JavaScript IIFEs

2017-05-09 Thread Martin Probst via Phabricator via cfe-commits
mprobst accepted this revision. mprobst added inline comments. This revision is now accepted and ready to land. Comment at: unittests/Format/FormatTestJS.cpp:371 +TEST_F(FormatTestJS, IIFE) { + verifyFormat("(function() {\n" + "var a = 1;\n"

[PATCH] D32989: Don't indent JavaScript IIFEs

2017-05-09 Thread Dan Beam via Phabricator via cfe-commits
danbeam added inline comments. Comment at: lib/Format/UnwrappedLineParser.cpp:2353 + // expressions? + if (Line->Tokens.size() < 5) +return false; mprobst wrote: > There's a `startsSequenceInternal` on `Line` that might come in handy here? it wasn't on

[PATCH] D32989: Don't indent JavaScript IIFEs

2017-05-09 Thread Dan Beam via Phabricator via cfe-commits
danbeam updated this revision to Diff 98332. danbeam marked 4 inline comments as done. danbeam added a comment. mprobst@ review https://reviews.llvm.org/D32989 Files: lib/Format/UnwrappedLineParser.cpp unittests/Format/FormatTestJS.cpp Index: unittests/Format/FormatTestJS.cpp

[PATCH] D32989: Don't indent JavaScript IIFEs

2017-05-09 Thread Martin Probst via Phabricator via cfe-commits
mprobst added inline comments. Comment at: lib/Format/UnwrappedLineParser.cpp:2362 + ++I; + if (I->Tok->isNot(tok::l_paren)) +return false; One more - do we want to support IIFEs that take arguments? ``` (function(global) { ... }(window)); ```

[PATCH] D32989: Don't indent JavaScript IIFEs

2017-05-09 Thread Martin Probst via Phabricator via cfe-commits
mprobst added inline comments. Comment at: lib/Format/UnwrappedLineParser.cpp:2346 +bool UnwrappedLineParser::isIIFE() const { + // Look for the start of an immediately invoked anonymous function. Why not just a static function? Comment at:

[PATCH] D32989: Don't indent JavaScript IIFEs

2017-05-08 Thread Dan Beam via Phabricator via cfe-commits
danbeam created this revision. Herald added a subscriber: klimek. Because IIFEs[1] are often used like an anonymous namespace around large sections of JavaScript code, it's useful not to indent to them (which effectively reduces the column limit by the indent amount needlessly). It's also common