Skip to main content

layer_conform_core/
function_ref.rs

1//! Per-function metadata returned by language analyzers.
2
3use compact_str::CompactString;
4
5use crate::ignore_parse::IgnoreDirective;
6use crate::tree::TreeNode;
7
8#[derive(Clone, Copy, Debug, PartialEq, Eq)]
9pub enum FunctionKind {
10    FunctionDeclaration,
11    VariableArrow,
12    ObjectMethod,
13    ClassMethod,
14    ClassPropertyArrow,
15    DefaultExportFunction,
16}
17
18#[derive(Clone, Debug, Default, PartialEq, Eq)]
19pub struct Signature {
20    pub param_count: u32,
21}
22
23#[derive(Clone, Debug)]
24pub struct FunctionRef {
25    pub symbol: CompactString,
26    pub kind: FunctionKind,
27    pub start_line: u32,
28    pub end_line: u32,
29    pub byte_range: (u32, u32),
30    pub tree: TreeNode,
31    pub signature: Signature,
32    pub calls: Vec<CompactString>,
33    pub imports: Vec<CompactString>,
34    pub ast_hash: [u8; 32],
35    /// `Some` when a `layer-conform-ignore` directive precedes the function.
36    /// Pipeline must skip ignored functions when detecting deviations.
37    pub ignore: Option<IgnoreDirective>,
38}