Changeset 196098 in webkit
- Timestamp:
- Feb 3, 2016 4:56:22 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r196084 r196098 1 2016-02-03 Joseph Pecoraro <pecoraro@apple.com> 2 3 Web Inspector: JS PrettyPrinting unary - and + issues 4 https://bugs.webkit.org/show_bug.cgi?id=134007 5 <rdar://problem/17351953> 6 7 Reviewed by Timothy Hatcher. 8 9 * inspector/codemirror/prettyprinting-javascript-expected.txt: 10 * inspector/codemirror/prettyprinting-javascript.html: 11 * inspector/codemirror/resources/prettyprinting/javascript-tests/unary-binary-operators-expected.js: Added. 12 * inspector/codemirror/resources/prettyprinting/javascript-tests/unary-binary-operators.js: Added. 13 New tests for unary and some binary operators in JavaScript pretty printing. 14 1 15 2016-02-03 Brent Fulgham <bfulgham@apple.com> 2 16 -
trunk/LayoutTests/inspector/codemirror/prettyprinting-javascript-expected.txt
r189500 r196098 12 12 PASS 13 13 14 -- Running test case: CodeMirror.PrettyPrinting.JavaScript.unary-binary-operators.js 15 PASS 16 -
trunk/LayoutTests/inspector/codemirror/prettyprinting-javascript.html
r189500 r196098 13 13 "resources/prettyprinting/javascript-tests/single-statement-blocks.js", 14 14 "resources/prettyprinting/javascript-tests/switch-case-default.js", 15 "resources/prettyprinting/javascript-tests/unary-binary-operators.js", 15 16 ]); 16 17 -
trunk/Source/WebInspectorUI/ChangeLog
r196076 r196098 1 2016-02-03 Joseph Pecoraro <pecoraro@apple.com> 2 3 Web Inspector: JS PrettyPrinting unary - and + issues 4 https://bugs.webkit.org/show_bug.cgi?id=134007 5 <rdar://problem/17351953> 6 7 Reviewed by Timothy Hatcher. 8 9 * UserInterface/Views/CodeMirrorFormatters.js: 10 (shouldHaveSpaceBeforeToken): 11 (shouldHaveSpaceAfterLastToken): 12 (removeLastNewline): 13 (modifyStateForTokenPre): 14 (modifyStateForTokenPost): 15 1 16 2016-02-03 Dave Hyatt <hyatt@apple.com> 2 17 -
trunk/Source/WebInspectorUI/UserInterface/Views/CodeMirrorFormatters.js
r188325 r196098 36 36 return lastToken && /\bkeyword\b/.test(lastToken) && (lastContent !== "function" && lastContent !== "typeof" && lastContent !== "instanceof"); 37 37 if (content === ":") // Ternary. 38 return (state.lexical.type === "stat" || state.lexical.type === ")" );38 return (state.lexical.type === "stat" || state.lexical.type === ")" || state.lexical.type === "]"); 39 39 return false; 40 40 } … … 44 44 45 45 if (/\boperator\b/.test(token)) { 46 if (!lastToken && (content === "+" || content === "-" || content === "~") && (lastContent !== ")" && lastContent !== "]")) // Possible Unary +/-. 47 return false; 46 48 if (content === "!") // Unary ! should not be confused with "!=". 47 49 return false; 48 return "+-/* &&||!===+=-=>=<=?".indexOf(content) >= 0; // Operators.50 return "+-/*%&&||!===+=-=>=<=?".indexOf(content) >= 0; // Operators. 49 51 } 50 52 … … 87 89 return false; 88 90 89 return ",+-/*&&||:!===+=-=>=<=?".indexOf(lastContent) >= 0; // Operators. 91 // If this unary operator did not have a leading expression it is probably unary. 92 if ((lastContent === "+" || lastContent === "-" || lastContent === "~") && !state._jsPrettyPrint.unaryOperatorHadLeadingExpr) 93 return false; 94 95 return ",+-/*%&&||:!===+=-=>=<=?".indexOf(lastContent) >= 0; // Operators. 90 96 }, 91 97 … … 121 127 return "};".indexOf(lastContent) >= 0; 122 128 if (content === ":") // Ternary. 123 return lastContent === "}" && (state.lexical.type === "stat" || state.lexical.type === ")" );129 return lastContent === "}" && (state.lexical.type === "stat" || state.lexical.type === ")" || state.lexical.type === "]"); 124 130 if (",().".indexOf(content) >= 0) // "})", "}.bind", "function() { ... }()", or "}, false)". 125 131 return lastContent === "}"; … … 195 201 openBraceStartMarkers: [], // Keep track of non-single statement blocks. 196 202 openBraceTrackingCount: -1, // Keep track of "{" and "}" in non-single statement blocks. 203 unaryOperatorHadLeadingExpr: false, // Try to detect if a unary operator had a leading expression and therefore may be binary. 197 204 }; 198 205 } … … 304 311 state._jsPrettyPrint.shouldDedent = false; 305 312 } 313 314 if ((content === "+" || content === "-" || content === "~") && (lastContent === ")" || lastContent === "]" || /\b(?:variable|number)\b/.test(lastToken))) 315 state._jsPrettyPrint.unaryOperatorHadLeadingExpr = true; 316 else 317 state._jsPrettyPrint.unaryOperatorHadLeadingExpr = false; 306 318 } 307 319 });
Note: See TracChangeset
for help on using the changeset viewer.