[PATCH] D32989: Don't indent JavaScript IIFEs
Dan Beam via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 9 11:49:19 PDT 2017
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 `Line` and unfortunately some of the state that `startsSequence` relies on isn't set up yet (at least as far as I know, I'm in a foreign land)
================
Comment at: lib/Format/UnwrappedLineParser.cpp:2362
+ ++I;
+ if (I->Tok->isNot(tok::l_paren))
+ return false;
----------------
mprobst wrote:
> One more - do we want to support IIFEs that take arguments?
>
>
> ```
> (function(global) {
> ...
> }(window));
> ```
"Less is more"
================
Comment at: unittests/Format/FormatTestJS.cpp:371
+TEST_F(FormatTestJS, IIFE) {
+ verifyFormat("(function() {\n"
+ "var a = 1;\n"
----------------
mprobst wrote:
> consider adding a test with comments between the tokens (which should work with `startsSequence`).
not done yet, but seems uncommon.
do you want me to add a FIXME?
https://reviews.llvm.org/D32989
More information about the cfe-commits
mailing list