Skip to content

Commit 78dcdee

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: #30907 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent b14440f commit 78dcdee

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
Error,
4847
MathMax,
4948
NumberIsNaN,
@@ -1291,40 +1290,23 @@ function complete(line, callback) {
12911290
// Resolve expr and get its completions.
12921291
const memberGroups = [];
12931292
if (!expr) {
1294-
// If context is instance of vm.ScriptContext
12951293
// Get global vars synchronously
1296-
if (this.useGlobal || vm.isContext(this.context)) {
1297-
completionGroups.push(getGlobalLexicalScopeNames(this[kContextId]));
1298-
let contextProto = this.context;
1299-
while (contextProto = ObjectGetPrototypeOf(contextProto)) {
1300-
completionGroups.push(
1301-
filteredOwnPropertyNames.call(this, contextProto));
1302-
}
1303-
const contextOwnNames =
1304-
filteredOwnPropertyNames.call(this, this.context);
1305-
if (!this.useGlobal) {
1306-
// When the context is not `global`, builtins are not own
1307-
// properties of it.
1308-
contextOwnNames.push(...globalBuiltins);
1309-
}
1310-
completionGroups.push(contextOwnNames);
1311-
if (filter !== '') addCommonWords(completionGroups);
1312-
completionGroupsLoaded();
1313-
} else {
1314-
this.eval('.scope', this.context, 'repl', function ev(err, globals) {
1315-
if (err || !ArrayIsArray(globals)) {
1316-
if (filter !== '') addCommonWords(completionGroups);
1317-
} else if (ArrayIsArray(globals[0])) {
1318-
// Add grouped globals
1319-
for (let n = 0; n < globals.length; n++)
1320-
completionGroups.push(globals[n]);
1321-
} else {
1322-
completionGroups.push(globals);
1323-
if (filter !== '') addCommonWords(completionGroups);
1324-
}
1325-
completionGroupsLoaded();
1326-
});
1294+
completionGroups.push(getGlobalLexicalScopeNames(this[kContextId]));
1295+
let contextProto = this.context;
1296+
while (contextProto = ObjectGetPrototypeOf(contextProto)) {
1297+
completionGroups.push(
1298+
filteredOwnPropertyNames.call(this, contextProto));
1299+
}
1300+
const contextOwnNames =
1301+
filteredOwnPropertyNames.call(this, this.context);
1302+
if (!this.useGlobal) {
1303+
// When the context is not `global`, builtins are not own
1304+
// properties of it.
1305+
contextOwnNames.push(...globalBuiltins);
13271306
}
1307+
completionGroups.push(contextOwnNames);
1308+
if (filter !== '') addCommonWords(completionGroups);
1309+
completionGroupsLoaded();
13281310
} else {
13291311
const evalExpr = `try { ${expr} } catch {}`;
13301312
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)