Skip to content

Commit d549dae

Browse files
BridgeARMylesBorins
authored andcommitted
repl: remove dead code
The .scope command was used only in the old debugger. Since that's not part of core anymore it's does not have any use. I tried to replicate the expected behavior but it even results in just exiting the repl immediately when using the completion similar to the removed test case. PR-URL: #30907 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 69aaab0 commit d549dae

File tree

2 files changed

+15
-57
lines changed

2 files changed

+15
-57
lines changed

lib/repl.js

+15-33
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
'use strict';
4444

4545
const {
46-
ArrayIsArray,
4746
MathMax,
4847
NumberIsNaN,
4948
ObjectAssign,
@@ -1277,40 +1276,23 @@ function complete(line, callback) {
12771276
// Resolve expr and get its completions.
12781277
const memberGroups = [];
12791278
if (!expr) {
1280-
// If context is instance of vm.ScriptContext
12811279
// Get global vars synchronously
1282-
if (this.useGlobal || vm.isContext(this.context)) {
1283-
completionGroups.push(getGlobalLexicalScopeNames(this[kContextId]));
1284-
let contextProto = this.context;
1285-
while (contextProto = ObjectGetPrototypeOf(contextProto)) {
1286-
completionGroups.push(
1287-
filteredOwnPropertyNames.call(this, contextProto));
1288-
}
1289-
const contextOwnNames =
1290-
filteredOwnPropertyNames.call(this, this.context);
1291-
if (!this.useGlobal) {
1292-
// When the context is not `global`, builtins are not own
1293-
// properties of it.
1294-
contextOwnNames.push(...globalBuiltins);
1295-
}
1296-
completionGroups.push(contextOwnNames);
1297-
if (filter !== '') addCommonWords(completionGroups);
1298-
completionGroupsLoaded();
1299-
} else {
1300-
this.eval('.scope', this.context, 'repl', function ev(err, globals) {
1301-
if (err || !ArrayIsArray(globals)) {
1302-
if (filter !== '') addCommonWords(completionGroups);
1303-
} else if (ArrayIsArray(globals[0])) {
1304-
// Add grouped globals
1305-
for (let n = 0; n < globals.length; n++)
1306-
completionGroups.push(globals[n]);
1307-
} else {
1308-
completionGroups.push(globals);
1309-
if (filter !== '') addCommonWords(completionGroups);
1310-
}
1311-
completionGroupsLoaded();
1312-
});
1280+
completionGroups.push(getGlobalLexicalScopeNames(this[kContextId]));
1281+
let contextProto = this.context;
1282+
while (contextProto = ObjectGetPrototypeOf(contextProto)) {
1283+
completionGroups.push(
1284+
filteredOwnPropertyNames.call(this, contextProto));
1285+
}
1286+
const contextOwnNames =
1287+
filteredOwnPropertyNames.call(this, this.context);
1288+
if (!this.useGlobal) {
1289+
// When the context is not `global`, builtins are not own
1290+
// properties of it.
1291+
contextOwnNames.push(...globalBuiltins);
13131292
}
1293+
completionGroups.push(contextOwnNames);
1294+
if (filter !== '') addCommonWords(completionGroups);
1295+
completionGroupsLoaded();
13141296
} else {
13151297
const evalExpr = `try { ${expr} } catch {}`;
13161298
this.eval(evalExpr, this.context, 'repl', (e, obj) => {

test/parallel/test-repl-eval-scope.js

-24
This file was deleted.

0 commit comments

Comments
 (0)