Skip to content

Commit

Permalink
better labelling
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Dec 15, 2024
1 parent 86eab1c commit ae3d8a1
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ export function CallExpression(node, context) {
if (node.arguments[0]) {
context.state.scope.tracing = b.thunk(/** @type {Expression} */ (node.arguments[0]));
} else {
const label = get_function_label(context.path.slice(0, -2));
const label = get_function_label(context.path.slice(0, -2)) ?? 'trace';
const loc = `(${locate_node(fn)})`;

context.state.scope.tracing = b.thunk(b.literal(label ? label + ' ' + loc : loc));
context.state.scope.tracing = b.thunk(b.literal(label + ' ' + loc));
}
}

Expand Down Expand Up @@ -245,4 +245,8 @@ function get_function_label(nodes) {
if (parent.type === 'Property' && !parent.computed) {
return /** @type {Identifier} */ (parent.key).name;
}

if (parent.type === 'VariableDeclarator' && parent.id.type === 'Identifier') {
return parent.id.name;
}
}

0 comments on commit ae3d8a1

Please sign in to comment.