Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/extractors/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,11 @@ export function extractSymbols(tree, _filePath) {
if (callInfo) {
calls.push(callInfo);
}
if (fn.type === 'member_expression') {
const cbDef = extractCallbackDefinition(node, fn);
if (cbDef) definitions.push(cbDef);
}
}
const cbDef = extractCallbackDefinition(node);
if (cbDef) definitions.push(cbDef);
break;
}

Expand Down Expand Up @@ -320,10 +322,6 @@ function extractReceiverName(objNode) {
if (objNode.type === 'identifier') return objNode.text;
if (objNode.type === 'this') return 'this';
if (objNode.type === 'super') return 'super';
if (objNode.type === 'member_expression') {
const prop = objNode.childForFieldName('property');
if (prop) return objNode.text;
}
return objNode.text;
}

Expand Down Expand Up @@ -432,8 +430,8 @@ const EXPRESS_METHODS = new Set([
]);
const EVENT_METHODS = new Set(['on', 'once', 'addEventListener', 'addListener']);

function extractCallbackDefinition(callNode) {
const fn = callNode.childForFieldName('function');
function extractCallbackDefinition(callNode, fn) {
if (!fn) fn = callNode.childForFieldName('function');
if (!fn || fn.type !== 'member_expression') return null;

const prop = fn.childForFieldName('property');
Expand Down
Loading