Skip to main content

count_top_level_functions

Function count_top_level_functions 

Source
pub fn count_top_level_functions(ast: &File) -> usize
Expand description

Count the number of top-level functions in an AST file.

“Top-level” means:

  • FunctionDeclaration at program body level
  • FunctionExpression/ArrowFunctionExpression in a VariableDeclarator at program body level
  • FunctionDeclaration inside ExportNamedDeclaration
  • FunctionDeclaration/FunctionExpression/ArrowFunctionExpression inside ExportDefaultDeclaration
  • VariableDeclaration with function expressions inside ExportNamedDeclaration

This matches the TS test binary’s traversal behavior.