Skip to main content

mago_analyzer/plugin/hook/
statement.rs

1//! Statement hooks for intercepting statement analysis.
2
3use mago_syntax::ast::Statement;
4
5use crate::plugin::context::HookContext;
6use crate::plugin::hook::HookAction;
7use crate::plugin::hook::HookResult;
8use crate::plugin::provider::Provider;
9
10/// Hook trait for intercepting statement analysis.
11///
12/// This hook receives the real AST statement and full mutable context,
13/// allowing hooks to inspect statements, report issues, and modify analysis state.
14pub trait StatementHook: Provider {
15    /// Called before a statement is analyzed.
16    ///
17    /// Return `HookAction::Continue` to proceed with normal analysis, or
18    /// `HookAction::Skip` to skip analysis of this statement.
19    fn before_statement(&self, _stmt: &Statement<'_>, _context: &mut HookContext<'_, '_>) -> HookResult<HookAction> {
20        Ok(HookAction::Continue)
21    }
22
23    /// Called after a statement has been analyzed.
24    fn after_statement(&self, _stmt: &Statement<'_>, _context: &mut HookContext<'_, '_>) -> HookResult<()> {
25        Ok(())
26    }
27}