Modified: trunk/LayoutTests/inspector/unit-tests/array-utilities.html (249184 => 249185)
--- trunk/LayoutTests/inspector/unit-tests/array-utilities.html 2019-08-27 23:48:54 UTC (rev 249184)
+++ trunk/LayoutTests/inspector/unit-tests/array-utilities.html 2019-08-28 00:10:47 UTC (rev 249185)
@@ -304,21 +304,6 @@
}
});
- suite.addTestCase({
- name: "Array.prototype.keySet",
- test() {
- let arr1 = ["abc", "def", "xyz"];
- let keySet = arr1.keySet();
- InspectorTest.expectShallowEqual(Object.keys(keySet), arr1, "keySet should create an object with keys equal to the array values.");
- InspectorTest.expectShallowEqual(Object.values(keySet), [true, true, true], "keySet should create an object with all values equal to true.");
-
- let arr2 = [1, 2, 3];
- InspectorTest.expectShallowEqual(Object.keys(arr2.keySet()), arr2.map(x => x.toString()), "keySet should create an object with keys equal to stringified array values.");
-
- return true;
- }
- });
-
suite.runTestCasesAndFinish();
}
</script>
Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js (249184 => 249185)
--- trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js 2019-08-27 23:48:54 UTC (rev 249184)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js 2019-08-28 00:10:47 UTC (rev 249185)
@@ -690,17 +690,6 @@
}
});
-Object.defineProperty(Array.prototype, "keySet",
-{
- value()
- {
- let keys = Object.create(null);
- for (var i = 0; i < this.length; ++i)
- keys[this[i]] = true;
- return keys;
- }
-});
-
Object.defineProperty(Array.prototype, "partition",
{
value(callback)
Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js (249184 => 249185)
--- trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js 2019-08-27 23:48:54 UTC (rev 249184)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/CodeMirrorCompletionController.js 2019-08-28 00:10:47 UTC (rev 249185)
@@ -654,7 +654,7 @@
// FIXME: Include module keywords if we know this is a module environment.
// var moduleKeywords = ["default", "export", "import"];
- var allKeywords = [
+ const allKeywords = [
"break", "case", "catch", "class", "const", "continue", "debugger", "default",
"delete", "do", "else", "extends", "false", "finally", "for", "function",
"if", "in", "Infinity", "instanceof", "let", "NaN", "new", "null", "of",
@@ -661,29 +661,31 @@
"return", "static", "super", "switch", "this", "throw", "true", "try",
"typeof", "undefined", "var", "void", "while", "with", "yield"
];
- var valueKeywords = ["false", "Infinity", "NaN", "null", "this", "true", "undefined", "globalThis"];
+ const valueKeywords = ["false", "Infinity", "NaN", "null", "this", "true", "undefined", "globalThis"];
- var allowedKeywordsInsideBlocks = allKeywords.keySet();
- var allowedKeywordsWhenDeclaringVariable = valueKeywords.keySet();
- var allowedKeywordsInsideParenthesis = valueKeywords.concat(["class", "function"]).keySet();
- var allowedKeywordsInsideBrackets = allowedKeywordsInsideParenthesis;
- var allowedKeywordsOnlyInsideSwitch = ["case", "default"].keySet();
+ const allowedKeywordsInsideBlocks = new Set(allKeywords);
+ const allowedKeywordsWhenDeclaringVariable = new Set(valueKeywords);
+ const allowedKeywordsInsideParenthesis = new Set(valueKeywords.concat(["class", "function"]));
+ const allowedKeywordsInsideBrackets = allowedKeywordsInsideParenthesis;
+ const allowedKeywordsOnlyInsideSwitch = new Set(["case", "default"]);
function matchKeywords(keywords)
{
- matchingWords = matchingWords.concat(keywords.filter(function(word) {
- if (!insideSwitch && word in allowedKeywordsOnlyInsideSwitch)
- return false;
- if (insideBlock && !(word in allowedKeywordsInsideBlocks))
- return false;
- if (insideBrackets && !(word in allowedKeywordsInsideBrackets))
- return false;
- if (insideParenthesis && !(word in allowedKeywordsInsideParenthesis))
- return false;
- if (declaringVariable && !(word in allowedKeywordsWhenDeclaringVariable))
- return false;
- return word.startsWith(prefix);
- }));
+ for (let keyword of keywords) {
+ if (!insideSwitch && allowedKeywordsOnlyInsideSwitch.has(keyword))
+ continue;
+ if (insideBlock && !allowedKeywordsInsideBlocks.has(keyword))
+ continue;
+ if (insideBrackets && !allowedKeywordsInsideBrackets.has(keyword))
+ continue;
+ if (insideParenthesis && !allowedKeywordsInsideParenthesis.has(keyword))
+ continue;
+ if (declaringVariable && !allowedKeywordsWhenDeclaringVariable.has(keyword))
+ continue;
+ if (!keyword.startsWith(prefix))
+ continue;
+ matchingWords.push(keyword);
+ }
}
function matchVariables()
Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/_javascript_RuntimeCompletionProvider.js (249184 => 249185)
--- trunk/Source/WebInspectorUI/UserInterface/Controllers/_javascript_RuntimeCompletionProvider.js 2019-08-27 23:48:54 UTC (rev 249184)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/_javascript_RuntimeCompletionProvider.js 2019-08-28 00:10:47 UTC (rev 249185)
@@ -317,7 +317,7 @@
}
var completions = defaultCompletions;
- var knownCompletions = completions.keySet();
+ let knownCompletions = new Set(completions);
for (var i = 0; i < propertyNames.length; ++i) {
var property = propertyNames[i];
@@ -330,11 +330,11 @@
property = quoteUsed + property.escapeCharacters(quoteUsed + "\\") + (suffix !== quoteUsed ? quoteUsed : "");
}
- if (!property.startsWith(prefix) || property in knownCompletions)
+ if (!property.startsWith(prefix) || knownCompletions.has(property))
continue;
completions.push(property);
- knownCompletions[property] = true;
+ knownCompletions.add(property);
}
function compare(a, b)