detect_unreachable_code

Function detect_unreachable_code 

Source
pub fn detect_unreachable_code(
    source_text: &str,
    filename: &str,
    source_type: SourceType,
    module_id: ModuleId,
) -> Result<Vec<UnreachableCode>>
Expand description

Detect unreachable code in a JavaScript/TypeScript file.

This function uses a simple AST-based approach to detect code that appears after control flow terminators (return, throw, break, continue) in the same block. This is a simplified analysis and does not use full CFG.

§Arguments

  • source_text - The source code to analyze
  • filename - The filename (for reporting)
  • source_type - The type of source file
  • module_id - The module ID for the unreachable code entries

§Returns

Returns a vector of UnreachableCode entries, one for each unreachable statement detected.