UNPKG

agentsqripts

Version:

Comprehensive static code analysis toolkit for identifying technical debt, security vulnerabilities, performance issues, and code quality problems

42 lines (37 loc) 865 B
/** * @file Extract function information from AST * @description Single responsibility: Parse AST to find all function declarations */ const { walk } = require('../ast/astParser'); /** * Extract function information from AST */ function extractFunctions(ast) { const functions = []; walk.simple(ast, { FunctionDeclaration(node) { functions.push({ name: node.id ? node.id.name : 'anonymous', node, type: 'declaration' }); }, FunctionExpression(node) { const name = node.id ? node.id.name : 'anonymous'; functions.push({ name, node, type: 'expression' }); }, ArrowFunctionExpression(node) { functions.push({ name: 'arrow', node, type: 'arrow' }); } }); return functions; } module.exports = extractFunctions;