Skip to content

Commit

Permalink
repl: simplify repl autocompletion
Browse files Browse the repository at this point in the history
This simplifies calling `filteredOwnPropertyNames()`. The context
is not used in that function, so there's no need to call the function
as such.

PR-URL: #30907
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
BridgeAR authored and targos committed Apr 28, 2020
1 parent 78dcdee commit 9b893e1
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/repl.js
Expand Up @@ -1294,11 +1294,9 @@ function complete(line, callback) {
completionGroups.push(getGlobalLexicalScopeNames(this[kContextId]));
let contextProto = this.context;
while (contextProto = ObjectGetPrototypeOf(contextProto)) {
completionGroups.push(
filteredOwnPropertyNames.call(this, contextProto));
completionGroups.push(filteredOwnPropertyNames(contextProto));
}
const contextOwnNames =
filteredOwnPropertyNames.call(this, this.context);
const contextOwnNames = filteredOwnPropertyNames(this.context);
if (!this.useGlobal) {
// When the context is not `global`, builtins are not own
// properties of it.
Expand All @@ -1313,7 +1311,7 @@ function complete(line, callback) {
if (obj != null) {
if (typeof obj === 'object' || typeof obj === 'function') {
try {
memberGroups.push(filteredOwnPropertyNames.call(this, obj));
memberGroups.push(filteredOwnPropertyNames(obj));
} catch {
// Probably a Proxy object without `getOwnPropertyNames` trap.
// We simply ignore it here, as we don't want to break the
Expand All @@ -1331,7 +1329,7 @@ function complete(line, callback) {
p = obj.constructor ? obj.constructor.prototype : null;
}
while (p !== null) {
memberGroups.push(filteredOwnPropertyNames.call(this, p));
memberGroups.push(filteredOwnPropertyNames(p));
p = ObjectGetPrototypeOf(p);
// Circular refs possible? Let's guard against that.
sentinel--;
Expand Down

0 comments on commit 9b893e1

Please sign in to comment.