1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//! AST adapter layer for function discovery
//!
//! Global invariants enforced:
//! - Deterministic traversal order by (file, span.start)
//! - Formatting, comments, and whitespace must not affect results
use crate::language::{FunctionBody, SourceSpan};
/// Function identifier: (file_index, local_index)
///
/// IDs are internal only and must never appear in user output.
/// Generated deterministically during traversal.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct FunctionId {
pub file_index: usize,
pub local_index: usize,
}
/// Stable abstraction for a function node in the AST
#[derive(Debug, Clone)]
pub struct FunctionNode {
pub id: FunctionId,
pub name: Option<String>,
pub span: SourceSpan,
pub body: FunctionBody,
pub suppression_reason: Option<String>,
}
impl FunctionNode {
/// Extract the start line number from the span
///
/// Note: For backwards compatibility, this method still exists but now
/// simply returns the line number from the SourceSpan.
pub fn start_line(&self, _source_map: &swc_common::SourceMap) -> u32 {
self.span.start_line
}
/// Get the start line number directly from the span
pub fn line(&self) -> u32 {
self.span.start_line
}
}