MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / inspect_views

Function inspect_views

libatomic/src/review/impact.rs:83–150  ·  view source on GitHub ↗
(
    before_view: &RecordedSemanticView<'_>,
    after_view: &RecordedSemanticView<'_>,
    paths: &[String],
    parser: &mut ParserRegistry,
)

Source from the content-addressed store, hash-verified

81}
82
83pub(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}"));

Callers 2

inspectFunction · 0.85
inspectFunction · 0.85

Calls 9

analyze_semanticFunction · 0.85
changed_sourcesMethod · 0.80
select_contextMethod · 0.80
getMethod · 0.65
callableFunction · 0.50
collectMethod · 0.45
iterMethod · 0.45
cloneMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected