Apply compatibility policy to already-parsed shared semantic source sets.
(before: SourceSet, after: SourceSet, paths: &[String])
| 77 | |
| 78 | /// Apply compatibility policy to already-parsed shared semantic source sets. |
| 79 | pub fn analyze_semantic(before: SourceSet, after: SourceSet, paths: &[String]) -> ImpactReport { |
| 80 | let complete = before.complete && after.complete; |
| 81 | let mut report = ImpactReport { |
| 82 | source_selection_complete: Some(complete), |
| 83 | inspected_files_before: before.files.len(), |
| 84 | inspected_files_after: after.files.len(), |
| 85 | searched_files_before: before.searched_files, |
| 86 | searched_files_after: after.searched_files, |
| 87 | ..Default::default() |
| 88 | }; |
| 89 | report |
| 90 | .gaps |
| 91 | .extend(before.gaps.iter().map(|gap| format!("before: {gap}"))); |
| 92 | report |
| 93 | .gaps |
| 94 | .extend(after.gaps.iter().map(|gap| format!("after: {gap}"))); |
| 95 | let inventory_complete = before.paths_complete && after.paths_complete; |
| 96 | let old = SourceGraph::new(before.files, before.paths, inventory_complete); |
| 97 | let new = SourceGraph::new(after.files, after.paths, inventory_complete); |
| 98 | let paths: BTreeSet<_> = paths |
| 99 | .iter() |
| 100 | .filter(|path| atomic_semantic::is_supported(path)) |
| 101 | .map(String::as_str) |
| 102 | .collect(); |
| 103 | let mut roots = BTreeSet::new(); |
| 104 | for id in old |
| 105 | .symbols |
| 106 | .keys() |
| 107 | .chain(new.symbols.keys()) |
| 108 | .collect::<BTreeSet<_>>() |
| 109 | { |
| 110 | let before = old.symbols.get(id); |
| 111 | let after = new.symbols.get(id); |
| 112 | let symbol = after.or(before).unwrap(); |
| 113 | if !matches!( |
| 114 | symbol.entity.kind, |
| 115 | atomic_semantic::EntityKind::Function | atomic_semantic::EntityKind::Method |
| 116 | ) { |
| 117 | continue; |
| 118 | } |
| 119 | if after.is_none() |
| 120 | && new.paths.contains(&symbol.location.path) |
| 121 | && !new.files.contains_key(&symbol.location.path) |
| 122 | { |
| 123 | if paths.contains(symbol.location.path.as_str()) { |
| 124 | report.gaps.push(format!( |
| 125 | "{id}: after-source unavailable; deletion is not inferred" |
| 126 | )); |
| 127 | } |
| 128 | continue; |
| 129 | } |
| 130 | if old.ambiguous.contains(id) || new.ambiguous.contains(id) { |
| 131 | if paths.contains(symbol.location.path.as_str()) { |
| 132 | report.gaps.push(format!("{id}: ambiguous conditional/overloaded declaration; no root delta or caller verdict inferred")); |
| 133 | } |
| 134 | continue; |
| 135 | } |
| 136 | if !paths.contains(symbol.location.path.as_str()) |
no test coverage detected