https://bugs.webkit.org/show_bug.cgi?id=142428
Patch by Joseph Pecoraro <pecoraro@apple.com> on 2015-03-06
Reviewed by Timothy Hatcher.
* Tools/PrettyPrinting/CodeMirrorFormatters.js:
* UserInterface/Views/CodeMirrorFormatters.js:
Fix "case" and "default" indentation rules to only happen inside a switch.
* Tools/PrettyPrinting/js-tests/switch-case-default-expected.js:
* Tools/PrettyPrinting/js-tests/switch-case-default.js:
Add tests for "case" and "default" nested inside and outside of switches.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181205
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
2015-03-06 Joseph Pecoraro <pecoraro@apple.com>
+ Web Inspector: JS Pretty Printing: "case" or "default" outside of switch causes unbalanced indentation
+ https://bugs.webkit.org/show_bug.cgi?id=142428
+
+ Reviewed by Timothy Hatcher.
+
+ * Tools/PrettyPrinting/CodeMirrorFormatters.js:
+ * UserInterface/Views/CodeMirrorFormatters.js:
+ Fix "case" and "default" indentation rules to only happen inside a switch.
+
+ * Tools/PrettyPrinting/js-tests/switch-case-default-expected.js:
+ * Tools/PrettyPrinting/js-tests/switch-case-default.js:
+ Add tests for "case" and "default" nested inside and outside of switches.
+
+2015-03-06 Joseph Pecoraro <pecoraro@apple.com>
+
Web Inspector: ES6: Improved Support for Iterator Objects
https://bugs.webkit.org/show_bug.cgi?id=142420
indentAfterToken: function(lastToken, lastContent, token, state, content, isComment)
{
- return content === "{" || content === "case" || content === "default";
+ if (content === "{")
+ return true;
+
+ if (content === "case" || content === "default")
+ return state.lexical.type === "}" && state.lexical.prev && state.lexical.prev.type === "form"; // Switch case/default.
+
+ return false;
},
newlineBeforeToken: function(lastToken, lastContent, token, state, content, isComment)
+function Ctor1() {
+ this.case = 1;
+ this.something = 2;
+}
+function Ctor2() {
+ this.default = 1;
+ this.something = 2;
+}
+
switch (x) {
case "abc":
- return 1;
+ return this.default;
case "def":
- return 2;
+ return this.case;
default:
return 3;
}
-switch(x){case "abc":return 1;case "def":return 2;default:return 3;}
+function Ctor1(){this.case=1;this.something=2;}
+function Ctor2(){this.default=1;this.something=2;}
+
+switch(x){case "abc":return this.default;case "def":return this.case;default:return 3;}
switch(x){
case "abc":
indentAfterToken: function(lastToken, lastContent, token, state, content, isComment)
{
- return content === "{" || content === "case" || content === "default";
+ if (content === "{")
+ return true;
+
+ if (content === "case" || content === "default")
+ return state.lexical.type === "}" && state.lexical.prev && state.lexical.prev.type === "form"; // Switch case/default.
+
+ return false;
},
newlineBeforeToken: function(lastToken, lastContent, token, state, content, isComment)