Changeset 249185 in webkit
- Timestamp:
- Aug 27, 2019, 5:10:47 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/inspector/unit-tests/array-utilities-expected.txt (modified) (1 diff)
-
LayoutTests/inspector/unit-tests/array-utilities.html (modified) (1 diff)
-
Source/WebInspectorUI/ChangeLog (modified) (1 diff)
-
Source/WebInspectorUI/UserInterface/Base/Utilities.js (modified) (1 diff)
-
Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js (modified) (2 diffs)
-
Source/WebInspectorUI/UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r249183 r249185 1 2019-08-27 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: replace uses of added utility `Array.prototype.keySet` with an actual `Set` 4 https://bugs.webkit.org/show_bug.cgi?id=201194 5 6 Reviewed by Ross Kirsling. 7 8 * inspector/unit-tests/array-utilities.html: 9 * inspector/unit-tests/array-utilities-expected.txt: 10 1 11 2019-08-27 Justin Fan <justin_fan@apple.com> 2 12 -
trunk/LayoutTests/inspector/unit-tests/array-utilities-expected.txt
r245991 r249185 133 133 PASS: insertAtIndex with index greater than array length should insert at the end. 134 134 135 -- Running test case: Array.prototype.keySet136 PASS: keySet should create an object with keys equal to the array values.137 PASS: keySet should create an object with all values equal to true.138 PASS: keySet should create an object with keys equal to stringified array values.139 -
trunk/LayoutTests/inspector/unit-tests/array-utilities.html
r245991 r249185 305 305 }); 306 306 307 suite.addTestCase({308 name: "Array.prototype.keySet",309 test() {310 let arr1 = ["abc", "def", "xyz"];311 let keySet = arr1.keySet();312 InspectorTest.expectShallowEqual(Object.keys(keySet), arr1, "keySet should create an object with keys equal to the array values.");313 InspectorTest.expectShallowEqual(Object.values(keySet), [true, true, true], "keySet should create an object with all values equal to true.");314 315 let arr2 = [1, 2, 3];316 InspectorTest.expectShallowEqual(Object.keys(arr2.keySet()), arr2.map(x => x.toString()), "keySet should create an object with keys equal to stringified array values.");317 318 return true;319 }320 });321 322 307 suite.runTestCasesAndFinish(); 323 308 } -
trunk/Source/WebInspectorUI/ChangeLog
r249163 r249185 1 2019-08-27 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: replace uses of added utility `Array.prototype.keySet` with an actual `Set` 4 https://bugs.webkit.org/show_bug.cgi?id=201194 5 6 Reviewed by Ross Kirsling. 7 8 They both have basically the same functionality, with one difference being that a `Set` can 9 work with arrays that have non-string values. 10 11 * UserInterface/Base/Utilities.js: 12 (Array.prototype.keySet): Deleted. 13 * UserInterface/Controllers/CodeMirrorCompletionController.js: 14 (WI.CodeMirrorCompletionController.prototype._generateJavaScriptCompletions): 15 (WI.CodeMirrorCompletionController.prototype._generateJavaScriptCompletions.matchKeywords): 16 * UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js: 17 (WI.JavaScriptRuntimeCompletionProvider.completionControllerCompletionsNeeded.receivedPropertyNames): 18 1 19 2019-08-27 Devin Rousso <drousso@apple.com> 2 20 -
trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js
r248537 r249185 691 691 }); 692 692 693 Object.defineProperty(Array.prototype, "keySet",694 {695 value()696 {697 let keys = Object.create(null);698 for (var i = 0; i < this.length; ++i)699 keys[this[i]] = true;700 return keys;701 }702 });703 704 693 Object.defineProperty(Array.prototype, "partition", 705 694 { -
trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js
r239630 r249185 655 655 // var moduleKeywords = ["default", "export", "import"]; 656 656 657 varallKeywords = [657 const allKeywords = [ 658 658 "break", "case", "catch", "class", "const", "continue", "debugger", "default", 659 659 "delete", "do", "else", "extends", "false", "finally", "for", "function", … … 662 662 "typeof", "undefined", "var", "void", "while", "with", "yield" 663 663 ]; 664 varvalueKeywords = ["false", "Infinity", "NaN", "null", "this", "true", "undefined", "globalThis"];665 666 var allowedKeywordsInsideBlocks = allKeywords.keySet();667 var allowedKeywordsWhenDeclaringVariable = valueKeywords.keySet();668 var allowedKeywordsInsideParenthesis = valueKeywords.concat(["class", "function"]).keySet();669 varallowedKeywordsInsideBrackets = allowedKeywordsInsideParenthesis;670 var allowedKeywordsOnlyInsideSwitch = ["case", "default"].keySet();664 const valueKeywords = ["false", "Infinity", "NaN", "null", "this", "true", "undefined", "globalThis"]; 665 666 const allowedKeywordsInsideBlocks = new Set(allKeywords); 667 const allowedKeywordsWhenDeclaringVariable = new Set(valueKeywords); 668 const allowedKeywordsInsideParenthesis = new Set(valueKeywords.concat(["class", "function"])); 669 const allowedKeywordsInsideBrackets = allowedKeywordsInsideParenthesis; 670 const allowedKeywordsOnlyInsideSwitch = new Set(["case", "default"]); 671 671 672 672 function matchKeywords(keywords) 673 673 { 674 matchingWords = matchingWords.concat(keywords.filter(function(word) { 675 if (!insideSwitch && word in allowedKeywordsOnlyInsideSwitch) 676 return false; 677 if (insideBlock && !(word in allowedKeywordsInsideBlocks)) 678 return false; 679 if (insideBrackets && !(word in allowedKeywordsInsideBrackets)) 680 return false; 681 if (insideParenthesis && !(word in allowedKeywordsInsideParenthesis)) 682 return false; 683 if (declaringVariable && !(word in allowedKeywordsWhenDeclaringVariable)) 684 return false; 685 return word.startsWith(prefix); 686 })); 674 for (let keyword of keywords) { 675 if (!insideSwitch && allowedKeywordsOnlyInsideSwitch.has(keyword)) 676 continue; 677 if (insideBlock && !allowedKeywordsInsideBlocks.has(keyword)) 678 continue; 679 if (insideBrackets && !allowedKeywordsInsideBrackets.has(keyword)) 680 continue; 681 if (insideParenthesis && !allowedKeywordsInsideParenthesis.has(keyword)) 682 continue; 683 if (declaringVariable && !allowedKeywordsWhenDeclaringVariable.has(keyword)) 684 continue; 685 if (!keyword.startsWith(prefix)) 686 continue; 687 matchingWords.push(keyword); 688 } 687 689 } 688 690 -
trunk/Source/WebInspectorUI/UserInterface/Controllers/JavaScriptRuntimeCompletionProvider.js
r249078 r249185 318 318 319 319 var completions = defaultCompletions; 320 var knownCompletions = completions.keySet();320 let knownCompletions = new Set(completions); 321 321 322 322 for (var i = 0; i < propertyNames.length; ++i) { … … 331 331 } 332 332 333 if (!property.startsWith(prefix) || property in knownCompletions)333 if (!property.startsWith(prefix) || knownCompletions.has(property)) 334 334 continue; 335 335 336 336 completions.push(property); 337 knownCompletions [property] = true;337 knownCompletions.add(property); 338 338 } 339 339
Note:
See TracChangeset
for help on using the changeset viewer.