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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//! Data flow graph extraction and program slicing.
//!
//! Tracks how data flows through a function - variable definitions,
//! uses, and mutations. Supports forward and backward program slicing.
//!
//! # Program Slicing
//!
//! Program slicing extracts the subset of code relevant to a computation:
//! - **Backward slice**: What affects a given line? (debugging: "why is this value wrong?")
//! - **Forward slice**: What does a line affect? (refactoring: "what will this change break?")
//! - **Chop**: What statements lie on paths between two points?
//!
//! # Example
//!
//! ```ignore
//! use go_brrr::dfg::{slice, DFGInfo, SliceCriteria, backward_slice};
//!
//! let dfg: DFGInfo = /* ... */;
//! let criteria = SliceCriteria::at_line(42);
//! let result = backward_slice(&dfg, &criteria);
//! println!("Lines affecting line 42: {:?}", result.lines);
//! ```
// Re-export types
// Note: DFGInfo is used within this module; DataflowEdge and DataflowKind are
// re-exported from lib.rs for the public API.
pub use ;
// Re-export builder
pub use DfgBuilder;
// Re-export slice types and functions
// These are re-exported for the public API; not all are used within this module.
pub use ;
use crate;
/// Extract DFG for a function with explicit language specification.
///
/// This function allows overriding the language auto-detection, which is useful
/// for files without extensions or with non-standard extensions.
///
/// # Arguments
///
/// * `file` - Path to the source file
/// * `function` - Name of the function to extract DFG for
/// * `language` - Optional language override (e.g., "python", "typescript", "rust").
/// If `None`, language is auto-detected from file extension.
///
/// # Returns
///
/// The data flow graph for the specified function.
///
/// # Errors
///
/// Returns an error if:
/// - The file cannot be read
/// - The language is not supported
/// - The function is not found
/// - Parsing fails
/// Get backward slice: what affects the given line?
///
/// Convenience function that extracts DFG and computes slice in one call.
/// This function provides pure data-flow-only slicing (no control dependencies).
///
/// For more accurate slicing that includes control dependencies, use the PDG-based
/// slicing functions in [`crate::pdg`].
///
/// # Errors
///
/// Returns [`BrrrError::InvalidArgument`] if line is 0 (lines are 1-indexed).
// Public API - used by lib.rs's get_slice_dfg_only function