Chromium Code Reviews
DescriptionDevTools: make JSFormatter aware of parenthesized expressions
JavascriptFormatter calls _beforeVisit() to collect tokens before visiting AST
nodes. However, the Acorn-provided AST did not generate enough info to
distinguish when the last ')' appeared, and our formatter would incorrectly add
a new line and indent whenever it saw any ')'.
This resulted in bad cases with expressions within more than one set of
parentheses (`if ((c))a;else b`).
This CL turns on an Acorn flag 'preserveParens' in order to distinguish and
insert a new line only for ')'s outside of a parenthesized expression.
Other examples:
with((c))a;
for (i=0; i< 5; (i++)){a;}
while ((true))x;
BUG=708493
Review-Url: https://codereview.chromium.org/2823233004
Cr-Commit-Position: refs/heads/master@{#465874}
Committed: https://chromium.googlesource.com/chromium/src/+/079dd5c40c3a59e588777c794a533f40755f8402
Patch Set 1 #
Total comments: 2
Patch Set 2 : ac #
Messages
Total messages: 16 (8 generated)
|
||||||||||||||||||||||||||||||||||||||||||||||