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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! Node kinds classified as resource-management patterns.
//!
//! These node kinds correspond to the `resource_management` category in the
//! [`PatternCatalog`](crate::catalog::PatternCatalog).
use LazyLock;
use Regex;
/// Tree-sitter node kinds for resource-management patterns.
///
/// - `macro_invocation`: macro calls (e.g. `drop!`, `vec!`, `println!`)
pub const NODE_KINDS: & = &;
// Rust: logging macros that should fall through to the `logging` category.
// Same pattern as logging::RUST_RE — if a macro_invocation text matches,
// it is logging, not resource_management.
// ^(tracing|log):: — tracing::info!, log::debug!, etc.
// ^(println|eprintln|print|eprint|dbg)! — standard output macros
static RUST_LOGGING_RE: = new;
/// Return `true` when `text` indicates the `macro_invocation` is **not**
/// resource-management and should fall through to another category.
///
/// The semantic is **inverted** compared to the `matches_callee` functions:
/// `true` means "this macro is excluded from resource_management."
/// Currently the only exclusion is Rust logging macros (`tracing::*!`,
/// `log::*!`, `println!`, `eprintln!`, `print!`, `eprint!`, `dbg!`), which
/// belong in the `logging` category instead.
///
/// Other languages always return `false` — no macro disambiguation needed.
///
/// # Examples
///
/// ```rust
/// use sdivi_patterns::queries::resource_management::excludes_callee;
///
/// // Logging macros are excluded from resource_management in Rust.
/// assert!(excludes_callee("tracing::info!(\"hi\")", "rust"));
/// assert!(excludes_callee("println!(\"x\")", "rust"));
///
/// // Non-logging macros stay in resource_management.
/// assert!(!excludes_callee("vec![1, 2, 3]", "rust"));
/// assert!(!excludes_callee("drop!(handle)", "rust"));
///
/// // Other languages never exclude.
/// assert!(!excludes_callee("tracing::info!(\"x\")", "typescript"));
/// ```