Skip to main content

debtmap/analyzers/rust/visitor/
helpers.rs

1//! Visitor helper functions
2//!
3//! Utility functions for the function visitor.
4
5use crate::analyzers::rust::types::FunctionContext;
6use std::path::PathBuf;
7
8/// Get line number from a span
9pub fn get_line_number(span: syn::__private::Span) -> usize {
10    span.start().line
11}
12
13/// Create function context from visitor state
14pub fn create_function_context(
15    name: String,
16    file: PathBuf,
17    line: usize,
18    is_trait_method: bool,
19    in_test_module: bool,
20    impl_type_name: Option<String>,
21    trait_name: Option<String>,
22) -> FunctionContext {
23    FunctionContext {
24        name,
25        file,
26        line,
27        is_trait_method,
28        in_test_module,
29        impl_type_name,
30        trait_name,
31    }
32}