mirror of
https://github.com/nodejs/node.git
synced 2025-05-20 01:45:06 +00:00
repl: simplify repl autocompletion
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: https://github.com/nodejs/node/pull/30907 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
parent
7327f390f6
commit
37f6a42f72
10
lib/repl.js
10
lib/repl.js
@ -1280,11 +1280,9 @@ function complete(line, callback) {
|
|||||||
completionGroups.push(getGlobalLexicalScopeNames(this[kContextId]));
|
completionGroups.push(getGlobalLexicalScopeNames(this[kContextId]));
|
||||||
let contextProto = this.context;
|
let contextProto = this.context;
|
||||||
while (contextProto = ObjectGetPrototypeOf(contextProto)) {
|
while (contextProto = ObjectGetPrototypeOf(contextProto)) {
|
||||||
completionGroups.push(
|
completionGroups.push(filteredOwnPropertyNames(contextProto));
|
||||||
filteredOwnPropertyNames.call(this, contextProto));
|
|
||||||
}
|
}
|
||||||
const contextOwnNames =
|
const contextOwnNames = filteredOwnPropertyNames(this.context);
|
||||||
filteredOwnPropertyNames.call(this, this.context);
|
|
||||||
if (!this.useGlobal) {
|
if (!this.useGlobal) {
|
||||||
// When the context is not `global`, builtins are not own
|
// When the context is not `global`, builtins are not own
|
||||||
// properties of it.
|
// properties of it.
|
||||||
@ -1299,7 +1297,7 @@ function complete(line, callback) {
|
|||||||
if (obj != null) {
|
if (obj != null) {
|
||||||
if (typeof obj === 'object' || typeof obj === 'function') {
|
if (typeof obj === 'object' || typeof obj === 'function') {
|
||||||
try {
|
try {
|
||||||
memberGroups.push(filteredOwnPropertyNames.call(this, obj));
|
memberGroups.push(filteredOwnPropertyNames(obj));
|
||||||
} catch {
|
} catch {
|
||||||
// Probably a Proxy object without `getOwnPropertyNames` trap.
|
// Probably a Proxy object without `getOwnPropertyNames` trap.
|
||||||
// We simply ignore it here, as we don't want to break the
|
// We simply ignore it here, as we don't want to break the
|
||||||
@ -1317,7 +1315,7 @@ function complete(line, callback) {
|
|||||||
p = obj.constructor ? obj.constructor.prototype : null;
|
p = obj.constructor ? obj.constructor.prototype : null;
|
||||||
}
|
}
|
||||||
while (p !== null) {
|
while (p !== null) {
|
||||||
memberGroups.push(filteredOwnPropertyNames.call(this, p));
|
memberGroups.push(filteredOwnPropertyNames(p));
|
||||||
p = ObjectGetPrototypeOf(p);
|
p = ObjectGetPrototypeOf(p);
|
||||||
// Circular refs possible? Let's guard against that.
|
// Circular refs possible? Let's guard against that.
|
||||||
sentinel--;
|
sentinel--;
|
||||||
|
Loading…
Reference in New Issue
Block a user