Skip to content

Commit

Permalink
repl: remove dead code
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
BridgeAR authored and MylesBorins committed Dec 17, 2019
1 parent 69aaab0 commit d549dae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 57 deletions.
48 changes: 15 additions & 33 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
'use strict';

const {
ArrayIsArray,
MathMax,
NumberIsNaN,
ObjectAssign,
Expand Down Expand Up @@ -1277,40 +1276,23 @@ function complete(line, callback) {
// Resolve expr and get its completions.
const memberGroups = [];
if (!expr) {
// If context is instance of vm.ScriptContext
// Get global vars synchronously
if (this.useGlobal || vm.isContext(this.context)) {
completionGroups.push(getGlobalLexicalScopeNames(this[kContextId]));
let contextProto = this.context;
while (contextProto = ObjectGetPrototypeOf(contextProto)) {
completionGroups.push(
filteredOwnPropertyNames.call(this, contextProto));
}
const contextOwnNames =
filteredOwnPropertyNames.call(this, this.context);
if (!this.useGlobal) {
// When the context is not `global`, builtins are not own
// properties of it.
contextOwnNames.push(...globalBuiltins);
}
completionGroups.push(contextOwnNames);
if (filter !== '') addCommonWords(completionGroups);
completionGroupsLoaded();
} else {
this.eval('.scope', this.context, 'repl', function ev(err, globals) {
if (err || !ArrayIsArray(globals)) {
if (filter !== '') addCommonWords(completionGroups);
} else if (ArrayIsArray(globals[0])) {
// Add grouped globals
for (let n = 0; n < globals.length; n++)
completionGroups.push(globals[n]);
} else {
completionGroups.push(globals);
if (filter !== '') addCommonWords(completionGroups);
}
completionGroupsLoaded();
});
completionGroups.push(getGlobalLexicalScopeNames(this[kContextId]));
let contextProto = this.context;
while (contextProto = ObjectGetPrototypeOf(contextProto)) {
completionGroups.push(
filteredOwnPropertyNames.call(this, contextProto));
}
const contextOwnNames =
filteredOwnPropertyNames.call(this, this.context);
if (!this.useGlobal) {
// When the context is not `global`, builtins are not own
// properties of it.
contextOwnNames.push(...globalBuiltins);
}
completionGroups.push(contextOwnNames);
if (filter !== '') addCommonWords(completionGroups);
completionGroupsLoaded();
} else {
const evalExpr = `try { ${expr} } catch {}`;
this.eval(evalExpr, this.context, 'repl', (e, obj) => {
Expand Down
24 changes: 0 additions & 24 deletions test/parallel/test-repl-eval-scope.js

This file was deleted.

0 comments on commit d549dae

Please sign in to comment.