Skip to content

Commit 2f98d80

Browse files
committed
show signatures of native functions
1 parent 5f478cb commit 2f98d80

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/NativeFunctions.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/repl.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const { processTopLevelAwait } = require('./await');
99
const { Runtime, mainContextIdPromise } = require('./inspector');
1010
const { strEscape, isIdentifier } = require('./util');
1111
const isRecoverableError = require('./recoverable');
12+
const NativeFunctions = require('./NativeFunctions');
1213

1314
// TODO(devsnek): make more robust
1415
Error.prepareStackTrace = (err, frames) => {
@@ -218,7 +219,7 @@ Prototype REPL - https://github.com/nodejs/repl`,
218219
return c;
219220
}
220221
}
221-
if (description.length < 10000) {
222+
if (description.length < 10000 && !description.includes('[native code]')) {
222223
let parsed = null;
223224
try {
224225
// Try to parse as a function, anonymous function, or arrow function.
@@ -285,6 +286,24 @@ Prototype REPL - https://github.com/nodejs/repl`,
285286
}
286287
}
287288
}
289+
} else if (expression.callee.type === 'MemberExpression') {
290+
const receiverSrc = buffer.slice(
291+
expression.callee.object.start,
292+
expression.callee.object.end,
293+
);
294+
const { result, exceptionDetails } = await this.eval(receiverSrc, false, true);
295+
if (!exceptionDetails) {
296+
const receiver = result.className;
297+
const { name } = parseDammit(evaluateResult.result.description).body[0].id;
298+
const entry = NativeFunctions.find((n) => n.receiver === receiver && n.name === name);
299+
if (entry.signatures) {
300+
this.functionCompletionCache.set(result.objectId, entry.signatures[0]);
301+
}
302+
const c = finishParams(entry.signatures[0]);
303+
if (c !== undefined) {
304+
return c;
305+
}
306+
}
288307
}
289308
}
290309
} else if (expression.type === 'MemberExpression') {

0 commit comments

Comments
 (0)