Skip to content

Commit 5b6e514

Browse files
BridgeARtargos
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: nodejs#30907 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent bf30154 commit 5b6e514

File tree

2 files changed

+15
-57
lines changed

2 files changed

+15
-57
lines changed

lib/repl.js

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
'use strict';
4444

4545
const {
46-
ArrayIsArray,
4746
Error,
4847
MathMax,
4948
NumberIsNaN,
@@ -1287,40 +1286,23 @@ function complete(line, callback) {
12871286
// Resolve expr and get its completions.
12881287
const memberGroups = [];
12891288
if (!expr) {
1290-
// If context is instance of vm.ScriptContext
12911289
// Get global vars synchronously
1292-
if (this.useGlobal || vm.isContext(this.context)) {
1293-
completionGroups.push(getGlobalLexicalScopeNames(this[kContextId]));
1294-
let contextProto = this.context;
1295-
while (contextProto = ObjectGetPrototypeOf(contextProto)) {
1296-
completionGroups.push(
1297-
filteredOwnPropertyNames.call(this, contextProto));
1298-
}
1299-
const contextOwnNames =
1300-
filteredOwnPropertyNames.call(this, this.context);
1301-
if (!this.useGlobal) {
1302-
// When the context is not `global`, builtins are not own
1303-
// properties of it.
1304-
contextOwnNames.push(...globalBuiltins);
1305-
}
1306-
completionGroups.push(contextOwnNames);
1307-
if (filter !== '') addCommonWords(completionGroups);
1308-
completionGroupsLoaded();
1309-
} else {
1310-
this.eval('.scope', this.context, 'repl', function ev(err, globals) {
1311-
if (err || !ArrayIsArray(globals)) {
1312-
if (filter !== '') addCommonWords(completionGroups);
1313-
} else if (ArrayIsArray(globals[0])) {
1314-
// Add grouped globals
1315-
for (let n = 0; n < globals.length; n++)
1316-
completionGroups.push(globals[n]);
1317-
} else {
1318-
completionGroups.push(globals);
1319-
if (filter !== '') addCommonWords(completionGroups);
1320-
}
1321-
completionGroupsLoaded();
1322-
});
1290+
completionGroups.push(getGlobalLexicalScopeNames(this[kContextId]));
1291+
let contextProto = this.context;
1292+
while (contextProto = ObjectGetPrototypeOf(contextProto)) {
1293+
completionGroups.push(
1294+
filteredOwnPropertyNames.call(this, contextProto));
1295+
}
1296+
const contextOwnNames =
1297+
filteredOwnPropertyNames.call(this, this.context);
1298+
if (!this.useGlobal) {
1299+
// When the context is not `global`, builtins are not own
1300+
// properties of it.
1301+
contextOwnNames.push(...globalBuiltins);
13231302
}
1303+
completionGroups.push(contextOwnNames);
1304+
if (filter !== '') addCommonWords(completionGroups);
1305+
completionGroupsLoaded();
13241306
} else {
13251307
const evalExpr = `try { ${expr} } catch {}`;
13261308
this.eval(evalExpr, this.context, 'repl', (e, obj) => {

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

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)