(
before_view: &RecordedSemanticView<'_>,
after_view: &RecordedSemanticView<'_>,
paths: &[String],
parser: &mut ParserRegistry,
)
| 81 | } |
| 82 | |
| 83 | pub(super) fn inspect_views( |
| 84 | before_view: &RecordedSemanticView<'_>, |
| 85 | after_view: &RecordedSemanticView<'_>, |
| 86 | paths: &[String], |
| 87 | parser: &mut ParserRegistry, |
| 88 | ) -> ImpactReport { |
| 89 | let before = before_view.changed_sources(paths, parser); |
| 90 | let after = after_view.changed_sources(paths, parser); |
| 91 | let callable = |kind: atomic_semantic::EntityKind| { |
| 92 | matches!( |
| 93 | kind, |
| 94 | atomic_semantic::EntityKind::Function | atomic_semantic::EntityKind::Method |
| 95 | ) |
| 96 | }; |
| 97 | let old: std::collections::BTreeMap<_, _> = before |
| 98 | .files |
| 99 | .iter() |
| 100 | .flat_map(|file| &file.symbols) |
| 101 | .filter(|symbol| callable(symbol.entity.kind)) |
| 102 | .map(|symbol| (&symbol.id, symbol)) |
| 103 | .collect(); |
| 104 | let new: std::collections::BTreeMap<_, _> = after |
| 105 | .files |
| 106 | .iter() |
| 107 | .flat_map(|file| &file.symbols) |
| 108 | .filter(|symbol| callable(symbol.entity.kind)) |
| 109 | .map(|symbol| (&symbol.id, symbol)) |
| 110 | .collect(); |
| 111 | let targets: Vec<_> = old |
| 112 | .values() |
| 113 | .chain(new.values()) |
| 114 | .filter(|symbol| { |
| 115 | !old.get(&symbol.id) |
| 116 | .zip(new.get(&symbol.id)) |
| 117 | .is_some_and(|(a, b)| { |
| 118 | a.tokens == b.tokens |
| 119 | && a.public == b.public |
| 120 | && a.restricted == b.restricted |
| 121 | && a.parent_visible == b.parent_visible |
| 122 | && a.conditional == b.conditional |
| 123 | }) |
| 124 | }) |
| 125 | .map(|symbol| (*symbol).clone()) |
| 126 | .collect(); |
| 127 | match ( |
| 128 | before_view.select_context(before, &targets, parser), |
| 129 | after_view.select_context(after, &targets, parser), |
| 130 | ) { |
| 131 | (Ok(before), Ok(after)) => atomic_audit::impact::analyze_semantic(before, after, paths), |
| 132 | (before, after) => { |
| 133 | let mut result = ImpactReport { |
| 134 | code_changed: true, |
| 135 | ..Default::default() |
| 136 | }; |
| 137 | if let Err(error) = before { |
| 138 | result |
| 139 | .gaps |
| 140 | .push(format!("Before semantic selection unavailable: {error}")); |
no test coverage detected