mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
util: rename CallSite.column to columnNumber
Align the property names `lineNumber` and `columnNumber`. PR-URL: https://github.com/nodejs/node/pull/56584 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
parent
97caa4cbb7
commit
1238f0afba
5 changed files with 17 additions and 5 deletions
|
@ -371,6 +371,9 @@ util.formatWithOptions({ colors: true }, 'See object %O', { foo: 42 });
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
added: v22.9.0
|
added: v22.9.0
|
||||||
changes:
|
changes:
|
||||||
|
- version: REPLACEME
|
||||||
|
pr-url: https://github.com/nodejs/node/pull/56584
|
||||||
|
description: Property `column` is deprecated in favor of `columnNumber`.
|
||||||
- version: REPLACEME
|
- version: REPLACEME
|
||||||
pr-url: https://github.com/nodejs/node/pull/56551
|
pr-url: https://github.com/nodejs/node/pull/56551
|
||||||
description: Property `CallSite.scriptId` is exposed.
|
description: Property `CallSite.scriptId` is exposed.
|
||||||
|
@ -391,8 +394,8 @@ changes:
|
||||||
* `scriptName` {string} Returns the name of the resource that contains the script for the
|
* `scriptName` {string} Returns the name of the resource that contains the script for the
|
||||||
function for this call site.
|
function for this call site.
|
||||||
* `scriptId` {string} Returns the unique id of the script, as in Chrome DevTools protocol [`Runtime.ScriptId`][].
|
* `scriptId` {string} Returns the unique id of the script, as in Chrome DevTools protocol [`Runtime.ScriptId`][].
|
||||||
* `lineNumber` {number} Returns the number, 1-based, of the line for the associate function call.
|
* `lineNumber` {number} Returns the JavaScript script line number (1-based).
|
||||||
* `column` {number} Returns the 1-based column offset on the line for the associated function call.
|
* `columnNumber` {number} Returns the JavaScript script column number (1-based).
|
||||||
|
|
||||||
Returns an array of call site objects containing the stack of
|
Returns an array of call site objects containing the stack of
|
||||||
the caller function.
|
the caller function.
|
||||||
|
@ -409,7 +412,7 @@ function exampleFunction() {
|
||||||
console.log(`Function Name: ${callSite.functionName}`);
|
console.log(`Function Name: ${callSite.functionName}`);
|
||||||
console.log(`Script Name: ${callSite.scriptName}`);
|
console.log(`Script Name: ${callSite.scriptName}`);
|
||||||
console.log(`Line Number: ${callSite.lineNumber}`);
|
console.log(`Line Number: ${callSite.lineNumber}`);
|
||||||
console.log(`Column Number: ${callSite.column}`);
|
console.log(`Column Number: ${callSite.columnNumber}`);
|
||||||
});
|
});
|
||||||
// CallSite 1:
|
// CallSite 1:
|
||||||
// Function Name: exampleFunction
|
// Function Name: exampleFunction
|
||||||
|
|
|
@ -348,10 +348,10 @@ const lazySourceMap = getLazy(() => require('internal/source_map/source_map_cach
|
||||||
* @returns {CallSite | undefined} // The reconstructed call site object
|
* @returns {CallSite | undefined} // The reconstructed call site object
|
||||||
*/
|
*/
|
||||||
function reconstructCallSite(callSite) {
|
function reconstructCallSite(callSite) {
|
||||||
const { scriptName, lineNumber, column } = callSite;
|
const { scriptName, lineNumber, columnNumber } = callSite;
|
||||||
const sourceMap = lazySourceMap().findSourceMap(scriptName);
|
const sourceMap = lazySourceMap().findSourceMap(scriptName);
|
||||||
if (!sourceMap) return;
|
if (!sourceMap) return;
|
||||||
const entry = sourceMap.findEntry(lineNumber - 1, column - 1);
|
const entry = sourceMap.findEntry(lineNumber - 1, columnNumber - 1);
|
||||||
if (!entry?.originalSource) return;
|
if (!entry?.originalSource) return;
|
||||||
return {
|
return {
|
||||||
__proto__: null,
|
__proto__: null,
|
||||||
|
@ -360,6 +360,7 @@ function reconstructCallSite(callSite) {
|
||||||
scriptName: entry.originalSource,
|
scriptName: entry.originalSource,
|
||||||
lineNumber: entry.originalLine + 1,
|
lineNumber: entry.originalLine + 1,
|
||||||
column: entry.originalColumn + 1,
|
column: entry.originalColumn + 1,
|
||||||
|
columnNumber: entry.originalColumn + 1,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,6 +99,7 @@
|
||||||
"transferList") \
|
"transferList") \
|
||||||
V(clone_untransferable_str, "Found invalid value in transferList.") \
|
V(clone_untransferable_str, "Found invalid value in transferList.") \
|
||||||
V(code_string, "code") \
|
V(code_string, "code") \
|
||||||
|
V(column_number_string, "columnNumber") \
|
||||||
V(column_string, "column") \
|
V(column_string, "column") \
|
||||||
V(commonjs_string, "commonjs") \
|
V(commonjs_string, "commonjs") \
|
||||||
V(config_string, "config") \
|
V(config_string, "config") \
|
||||||
|
|
|
@ -282,6 +282,8 @@ static void GetCallSites(const FunctionCallbackInfo<Value>& args) {
|
||||||
env->script_id_string(),
|
env->script_id_string(),
|
||||||
env->script_name_string(),
|
env->script_name_string(),
|
||||||
env->line_number_string(),
|
env->line_number_string(),
|
||||||
|
env->column_number_string(),
|
||||||
|
// TODO(legendecas): deprecate CallSite.column.
|
||||||
env->column_string(),
|
env->column_string(),
|
||||||
};
|
};
|
||||||
Local<Value> values[] = {
|
Local<Value> values[] = {
|
||||||
|
@ -290,6 +292,8 @@ static void GetCallSites(const FunctionCallbackInfo<Value>& args) {
|
||||||
script_name,
|
script_name,
|
||||||
Integer::NewFromUnsigned(isolate, stack_frame->GetLineNumber()),
|
Integer::NewFromUnsigned(isolate, stack_frame->GetLineNumber()),
|
||||||
Integer::NewFromUnsigned(isolate, stack_frame->GetColumn()),
|
Integer::NewFromUnsigned(isolate, stack_frame->GetColumn()),
|
||||||
|
// TODO(legendecas): deprecate CallSite.column.
|
||||||
|
Integer::NewFromUnsigned(isolate, stack_frame->GetColumn()),
|
||||||
};
|
};
|
||||||
Local<Object> obj = Object::New(
|
Local<Object> obj = Object::New(
|
||||||
isolate, v8::Null(isolate), names, values, arraysize(names));
|
isolate, v8::Null(isolate), names, values, arraysize(names));
|
||||||
|
|
|
@ -133,6 +133,7 @@ const assert = require('node:assert');
|
||||||
assert.strictEqual(stderr.toString(), '');
|
assert.strictEqual(stderr.toString(), '');
|
||||||
assert.match(output, /lineNumber: 8/);
|
assert.match(output, /lineNumber: 8/);
|
||||||
assert.match(output, /column: 18/);
|
assert.match(output, /column: 18/);
|
||||||
|
assert.match(output, /columnNumber: 18/);
|
||||||
assert.match(output, /test-get-callsite\.ts/);
|
assert.match(output, /test-get-callsite\.ts/);
|
||||||
assert.strictEqual(status, 0);
|
assert.strictEqual(status, 0);
|
||||||
}
|
}
|
||||||
|
@ -150,6 +151,7 @@ const assert = require('node:assert');
|
||||||
// Line should be wrong when sourcemaps are disable
|
// Line should be wrong when sourcemaps are disable
|
||||||
assert.match(output, /lineNumber: 2/);
|
assert.match(output, /lineNumber: 2/);
|
||||||
assert.match(output, /column: 18/);
|
assert.match(output, /column: 18/);
|
||||||
|
assert.match(output, /columnNumber: 18/);
|
||||||
assert.match(output, /test-get-callsite\.ts/);
|
assert.match(output, /test-get-callsite\.ts/);
|
||||||
assert.strictEqual(status, 0);
|
assert.strictEqual(status, 0);
|
||||||
}
|
}
|
||||||
|
@ -166,6 +168,7 @@ const assert = require('node:assert');
|
||||||
assert.strictEqual(stderr.toString(), '');
|
assert.strictEqual(stderr.toString(), '');
|
||||||
assert.match(output, /lineNumber: 2/);
|
assert.match(output, /lineNumber: 2/);
|
||||||
assert.match(output, /column: 18/);
|
assert.match(output, /column: 18/);
|
||||||
|
assert.match(output, /columnNumber: 18/);
|
||||||
assert.match(output, /test-get-callsite-explicit\.ts/);
|
assert.match(output, /test-get-callsite-explicit\.ts/);
|
||||||
assert.strictEqual(status, 0);
|
assert.strictEqual(status, 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue