dart-decimate 0.0.76 → 0.0.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +1 -1
- package/Cargo.toml +1 -1
- package/README.md +8 -8
- package/package.json +2 -2
- package/src/boundaries.rs +1 -9
- package/src/cli/analyze.rs +33 -3
- package/src/cli/error.rs +16 -0
- package/src/cli/list_run.rs +3 -1
- package/src/cli/scope_args.rs +14 -3
- package/src/config.rs +12 -8
- package/src/dart_parser.rs +100 -9
- package/src/dependencies/analyze.rs +4 -3
- package/src/dependencies/discovery.rs +10 -2
- package/src/dependencies/flutter_usage.rs +4 -0
- package/src/dependencies/tests.rs +5 -5
- package/src/dependencies/usage.rs +0 -9
- package/src/dependencies.rs +12 -7
- package/src/dupes/declarations.rs +1 -2
- package/src/dupes.rs +1 -10
- package/src/explain/misc.rs +1 -1
- package/src/explain.rs +1 -1
- package/src/extract/members.rs +24 -15
- package/src/extract/tests.rs +89 -0
- package/src/extract.rs +51 -15
- package/src/graph.rs +9 -0
- package/src/lib.rs +3 -2
- package/src/output/duplication_findings.rs +1 -2
- package/src/output/human.rs +7 -2
- package/src/output/human_details.rs +6 -0
- package/src/output/next_steps.rs +111 -0
- package/src/output/route_cycle/aliases.rs +1 -2
- package/src/output/route_cycle/wrappers.rs +1 -2
- package/src/output/types.rs +2 -0
- package/src/output.rs +27 -5
- package/src/outside/loader.rs +133 -0
- package/src/outside/loader_tests.rs +136 -0
- package/src/outside/resolver.rs +484 -0
- package/src/outside/tests.rs +242 -0
- package/src/outside.rs +186 -0
- package/src/package_map.rs +30 -1
- package/src/report_schema.rs +1 -0
- package/src/routes.rs +2 -0
- package/src/scan.rs +24 -3
- package/src/security/detect/process_arguments.rs +106 -0
- package/src/security/detect.rs +98 -40
- package/src/symbols/extensions.rs +42 -27
- package/src/symbols/path_filters.rs +10 -1
- package/src/symbols/tests.rs +15 -0
- package/src/symbols.rs +489 -67
- package/src/trace.rs +6 -5
- package/src/widgets/reads.rs +4 -8
- package/src/widgets/resolution.rs +63 -10
- package/src/workspace_scope.rs +1 -10
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
use std::collections::{BTreeMap, BTreeSet};
|
|
2
|
+
use std::path::{Path, PathBuf};
|
|
3
|
+
use std::rc::Rc;
|
|
4
|
+
|
|
5
|
+
use crate::widgets::resolution::{ClassKey, compact_reference, visible_through_combinators};
|
|
6
|
+
use crate::{DartFile, DartImport, DeclarationKind, MemberKind};
|
|
7
|
+
|
|
8
|
+
use super::loader::{Outline, SharedLoader};
|
|
9
|
+
use super::{OutsideSources, Target};
|
|
10
|
+
|
|
11
|
+
pub(crate) struct OutsideTypes {
|
|
12
|
+
reader: Option<Reader>,
|
|
13
|
+
lookups: BTreeMap<(PathBuf, String), Option<ClassKey>>,
|
|
14
|
+
pending: Vec<ClassKey>,
|
|
15
|
+
seen: BTreeSet<ClassKey>,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
#[derive(Default)]
|
|
19
|
+
pub(crate) struct OutsideClass {
|
|
20
|
+
pub(crate) extended: BTreeSet<ClassKey>,
|
|
21
|
+
pub(crate) mixed: BTreeSet<ClassKey>,
|
|
22
|
+
pub(crate) implemented: BTreeSet<ClassKey>,
|
|
23
|
+
pub(crate) unread_extended: BTreeSet<String>,
|
|
24
|
+
pub(crate) unread_interface: BTreeSet<String>,
|
|
25
|
+
pub(crate) names: BTreeSet<String>,
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
struct Reader {
|
|
29
|
+
sources: OutsideSources,
|
|
30
|
+
loader: SharedLoader,
|
|
31
|
+
library_of: BTreeMap<PathBuf, PathBuf>,
|
|
32
|
+
exported: BTreeMap<(PathBuf, String), Walk>,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
#[derive(Clone, Default)]
|
|
36
|
+
struct Walk {
|
|
37
|
+
classes: BTreeSet<ClassKey>,
|
|
38
|
+
complete: bool,
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
impl Walk {
|
|
42
|
+
fn empty() -> Self {
|
|
43
|
+
Self {
|
|
44
|
+
classes: BTreeSet::new(),
|
|
45
|
+
complete: true,
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
fn unread() -> Self {
|
|
50
|
+
Self {
|
|
51
|
+
classes: BTreeSet::new(),
|
|
52
|
+
complete: false,
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
impl OutsideTypes {
|
|
58
|
+
pub(crate) fn with_loader(
|
|
59
|
+
root: &Path,
|
|
60
|
+
loader: SharedLoader,
|
|
61
|
+
scanned: &Rc<BTreeSet<PathBuf>>,
|
|
62
|
+
) -> Self {
|
|
63
|
+
Self {
|
|
64
|
+
reader: OutsideSources::discover(root).map(|sources| Reader {
|
|
65
|
+
sources: sources.with_scanned(Rc::clone(scanned)),
|
|
66
|
+
loader,
|
|
67
|
+
library_of: BTreeMap::new(),
|
|
68
|
+
exported: BTreeMap::new(),
|
|
69
|
+
}),
|
|
70
|
+
lookups: BTreeMap::new(),
|
|
71
|
+
pending: Vec::new(),
|
|
72
|
+
seen: BTreeSet::new(),
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
pub(crate) fn link(
|
|
77
|
+
&mut self,
|
|
78
|
+
library: &Path,
|
|
79
|
+
imports: &[DartImport],
|
|
80
|
+
reference: &str,
|
|
81
|
+
from_outside: bool,
|
|
82
|
+
) -> Option<ClassKey> {
|
|
83
|
+
let reference = compact_reference(reference);
|
|
84
|
+
let key = (library.to_path_buf(), reference.clone());
|
|
85
|
+
let found = if let Some(known) = self.lookups.get(&key) {
|
|
86
|
+
known.clone()
|
|
87
|
+
} else {
|
|
88
|
+
let found = self
|
|
89
|
+
.reader
|
|
90
|
+
.as_mut()
|
|
91
|
+
.and_then(|reader| reader.lookup(library, imports, &reference, from_outside));
|
|
92
|
+
self.lookups.insert(key, found.clone());
|
|
93
|
+
found
|
|
94
|
+
};
|
|
95
|
+
if let Some(class) = &found
|
|
96
|
+
&& self.seen.insert(class.clone())
|
|
97
|
+
{
|
|
98
|
+
self.pending.push(class.clone());
|
|
99
|
+
}
|
|
100
|
+
found
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
pub(crate) fn has_package_config_gaps(&self) -> bool {
|
|
104
|
+
self.reader
|
|
105
|
+
.as_ref()
|
|
106
|
+
.is_some_and(|reader| reader.sources.gaps() > 0)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
pub(crate) fn expand(&mut self) -> BTreeMap<ClassKey, OutsideClass> {
|
|
110
|
+
let mut classes = BTreeMap::new();
|
|
111
|
+
while let Some(key) = self.pending.pop() {
|
|
112
|
+
let class = self.expand_class(&key);
|
|
113
|
+
classes.insert(key, class);
|
|
114
|
+
}
|
|
115
|
+
classes
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
fn expand_class(&mut self, key: &ClassKey) -> OutsideClass {
|
|
119
|
+
let Some(reader) = self.reader.as_mut() else {
|
|
120
|
+
return OutsideClass::default();
|
|
121
|
+
};
|
|
122
|
+
let library = reader
|
|
123
|
+
.library_of
|
|
124
|
+
.get(&key.path)
|
|
125
|
+
.cloned()
|
|
126
|
+
.unwrap_or_else(|| key.path.clone());
|
|
127
|
+
let (Outline::Read(file), Outline::Read(library_file)) = (
|
|
128
|
+
reader.load(&key.path, &key.name),
|
|
129
|
+
reader.load(&library, &key.name),
|
|
130
|
+
) else {
|
|
131
|
+
return OutsideClass {
|
|
132
|
+
unread_extended: BTreeSet::from([key.name.clone()]),
|
|
133
|
+
..OutsideClass::default()
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
let mut class = OutsideClass {
|
|
137
|
+
names: declared_names(&file, &key.name),
|
|
138
|
+
..OutsideClass::default()
|
|
139
|
+
};
|
|
140
|
+
let Some(clause) = file
|
|
141
|
+
.class_supertypes
|
|
142
|
+
.iter()
|
|
143
|
+
.find(|clause| clause.owner == key.name)
|
|
144
|
+
else {
|
|
145
|
+
return class;
|
|
146
|
+
};
|
|
147
|
+
let lists = [
|
|
148
|
+
(&clause.names, true, false),
|
|
149
|
+
(&clause.constraints, true, false),
|
|
150
|
+
(&clause.mixins, false, true),
|
|
151
|
+
(&clause.implemented, false, false),
|
|
152
|
+
];
|
|
153
|
+
for (references, extends, mixes) in lists {
|
|
154
|
+
for reference in references {
|
|
155
|
+
if matches!(reference.as_str(), "Object" | "core.Object") {
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
let target = self.link(&library, &library_file.imports, reference, true);
|
|
159
|
+
match target {
|
|
160
|
+
Some(target) if extends => {
|
|
161
|
+
class.extended.insert(target);
|
|
162
|
+
}
|
|
163
|
+
Some(target) if mixes => {
|
|
164
|
+
class.mixed.insert(target);
|
|
165
|
+
}
|
|
166
|
+
Some(target) => {
|
|
167
|
+
class.implemented.insert(target);
|
|
168
|
+
}
|
|
169
|
+
None if extends => {
|
|
170
|
+
class.unread_extended.insert(reference.clone());
|
|
171
|
+
}
|
|
172
|
+
None => {
|
|
173
|
+
class.unread_interface.insert(reference.clone());
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
class
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
fn declared_names(file: &DartFile, owner: &str) -> BTreeSet<String> {
|
|
183
|
+
file.members
|
|
184
|
+
.iter()
|
|
185
|
+
.filter(|member| {
|
|
186
|
+
member.owner == owner
|
|
187
|
+
&& !member.name.starts_with('_')
|
|
188
|
+
&& matches!(
|
|
189
|
+
member.kind,
|
|
190
|
+
MemberKind::Field
|
|
191
|
+
| MemberKind::Getter
|
|
192
|
+
| MemberKind::Setter
|
|
193
|
+
| MemberKind::Method
|
|
194
|
+
)
|
|
195
|
+
})
|
|
196
|
+
.map(|member| member.name.clone())
|
|
197
|
+
.collect()
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
fn declares(file: &DartFile, name: &str) -> bool {
|
|
201
|
+
file.declarations.iter().any(|declaration| {
|
|
202
|
+
declaration.name == name
|
|
203
|
+
&& matches!(
|
|
204
|
+
declaration.kind,
|
|
205
|
+
DeclarationKind::Class
|
|
206
|
+
| DeclarationKind::Mixin
|
|
207
|
+
| DeclarationKind::TypeAlias
|
|
208
|
+
| DeclarationKind::Enum
|
|
209
|
+
| DeclarationKind::ExtensionType
|
|
210
|
+
)
|
|
211
|
+
})
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
impl Reader {
|
|
215
|
+
fn gap(&self) -> Walk {
|
|
216
|
+
self.sources.note_gap(None);
|
|
217
|
+
Walk::unread()
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
fn load(&self, path: &Path, wanted: &str) -> Outline {
|
|
221
|
+
self.loader.borrow_mut().load(path, wanted)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
fn prefetch(&self, paths: &[PathBuf], wanted: &str) {
|
|
225
|
+
self.loader.borrow_mut().prefetch(paths, wanted);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
fn lookup(
|
|
229
|
+
&mut self,
|
|
230
|
+
library: &Path,
|
|
231
|
+
imports: &[DartImport],
|
|
232
|
+
reference: &str,
|
|
233
|
+
from_outside: bool,
|
|
234
|
+
) -> Option<ClassKey> {
|
|
235
|
+
let mut segments = reference.split('.');
|
|
236
|
+
let first = segments.next()?;
|
|
237
|
+
let second = segments.next();
|
|
238
|
+
if segments.next().is_some() {
|
|
239
|
+
return None;
|
|
240
|
+
}
|
|
241
|
+
let (prefix, name) = match second {
|
|
242
|
+
Some(name)
|
|
243
|
+
if imports
|
|
244
|
+
.iter()
|
|
245
|
+
.any(|import| import.prefix.as_deref() == Some(first)) =>
|
|
246
|
+
{
|
|
247
|
+
(Some(first), name)
|
|
248
|
+
}
|
|
249
|
+
Some(_) => return None,
|
|
250
|
+
None => (None, first),
|
|
251
|
+
};
|
|
252
|
+
if from_outside && prefix.is_none() {
|
|
253
|
+
let own = self.library_classes(library, name);
|
|
254
|
+
if !own.classes.is_empty() {
|
|
255
|
+
return exactly_one(own.classes);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
if name.starts_with('_') {
|
|
259
|
+
return None;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
let selected = imports
|
|
263
|
+
.iter()
|
|
264
|
+
.filter(|import| import.prefix.as_deref() == prefix)
|
|
265
|
+
.filter(|import| visible_through_combinators(name, &import.combinators))
|
|
266
|
+
.collect::<Vec<_>>();
|
|
267
|
+
let (core, others): (Vec<_>, Vec<_>) = selected
|
|
268
|
+
.into_iter()
|
|
269
|
+
.partition(|import| import.uri == "dart:core");
|
|
270
|
+
let explicit_core = imports.iter().any(|import| import.uri == "dart:core");
|
|
271
|
+
|
|
272
|
+
let (found, incomplete) = self.directive_classes(library, &others, name, from_outside);
|
|
273
|
+
if !found.is_empty() {
|
|
274
|
+
return exactly_one(found);
|
|
275
|
+
}
|
|
276
|
+
if incomplete {
|
|
277
|
+
return None;
|
|
278
|
+
}
|
|
279
|
+
let (found, _) = if explicit_core || prefix.is_some() {
|
|
280
|
+
self.directive_classes(library, &core, name, from_outside)
|
|
281
|
+
} else {
|
|
282
|
+
self.core_classes(name)
|
|
283
|
+
};
|
|
284
|
+
exactly_one(found)
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
fn core_classes(&mut self, name: &str) -> (BTreeSet<ClassKey>, bool) {
|
|
288
|
+
let core = self.sources.resolve(Path::new(""), "dart:core", true);
|
|
289
|
+
match core {
|
|
290
|
+
Target::Outside(path) => {
|
|
291
|
+
let walk = self.exported(&path, name);
|
|
292
|
+
(walk.classes, !walk.complete)
|
|
293
|
+
}
|
|
294
|
+
Target::Local | Target::Unknown => (BTreeSet::new(), true),
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
fn directive_classes(
|
|
299
|
+
&mut self,
|
|
300
|
+
library: &Path,
|
|
301
|
+
imports: &[&DartImport],
|
|
302
|
+
name: &str,
|
|
303
|
+
from_outside: bool,
|
|
304
|
+
) -> (BTreeSet<ClassKey>, bool) {
|
|
305
|
+
let mut groups = BTreeMap::<(usize, usize), Vec<&DartImport>>::new();
|
|
306
|
+
for import in imports {
|
|
307
|
+
groups
|
|
308
|
+
.entry((import.location.line, import.location.column))
|
|
309
|
+
.or_default()
|
|
310
|
+
.push(import);
|
|
311
|
+
}
|
|
312
|
+
let targets = imports
|
|
313
|
+
.iter()
|
|
314
|
+
.filter_map(
|
|
315
|
+
|import| match self.sources.resolve(library, &import.uri, from_outside) {
|
|
316
|
+
Target::Outside(path) => Some(path),
|
|
317
|
+
Target::Local | Target::Unknown => None,
|
|
318
|
+
},
|
|
319
|
+
)
|
|
320
|
+
.collect::<Vec<_>>();
|
|
321
|
+
self.prefetch(&targets, name);
|
|
322
|
+
let mut found = BTreeSet::new();
|
|
323
|
+
let mut matching = 0_usize;
|
|
324
|
+
let mut incomplete = false;
|
|
325
|
+
for branches in groups.into_values() {
|
|
326
|
+
let results = branches
|
|
327
|
+
.iter()
|
|
328
|
+
.map(
|
|
329
|
+
|import| match self.sources.resolve(library, &import.uri, from_outside) {
|
|
330
|
+
Target::Outside(path) => self.exported(&path, name),
|
|
331
|
+
Target::Local => Walk::empty(),
|
|
332
|
+
Target::Unknown => self.gap(),
|
|
333
|
+
},
|
|
334
|
+
)
|
|
335
|
+
.collect::<Vec<_>>();
|
|
336
|
+
let (classes, complete) = agree(&results);
|
|
337
|
+
incomplete |= !complete;
|
|
338
|
+
if !classes.is_empty() {
|
|
339
|
+
matching += 1;
|
|
340
|
+
found.extend(classes);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
if matching > 1 && found.len() > 1 {
|
|
344
|
+
incomplete = true;
|
|
345
|
+
found.clear();
|
|
346
|
+
}
|
|
347
|
+
(found, incomplete)
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
fn exported(&mut self, library: &Path, name: &str) -> Walk {
|
|
351
|
+
let key = (library.to_path_buf(), name.to_owned());
|
|
352
|
+
if let Some(walk) = self.exported.get(&key) {
|
|
353
|
+
return walk.clone();
|
|
354
|
+
}
|
|
355
|
+
let walk = self.export_walk(library, name, &mut BTreeSet::new());
|
|
356
|
+
self.exported.insert(key, walk.clone());
|
|
357
|
+
walk
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
fn export_walk(&mut self, library: &Path, name: &str, visited: &mut BTreeSet<PathBuf>) -> Walk {
|
|
361
|
+
if !visited.insert(library.to_path_buf()) {
|
|
362
|
+
return Walk::empty();
|
|
363
|
+
}
|
|
364
|
+
let own = self.library_classes(library, name);
|
|
365
|
+
let mut walk = Walk {
|
|
366
|
+
classes: own.classes,
|
|
367
|
+
complete: own.complete,
|
|
368
|
+
};
|
|
369
|
+
let Outline::Read(file) = self.load(library, name) else {
|
|
370
|
+
return walk;
|
|
371
|
+
};
|
|
372
|
+
let targets = file
|
|
373
|
+
.exports
|
|
374
|
+
.iter()
|
|
375
|
+
.filter(|export| visible_through_combinators(name, &export.combinators))
|
|
376
|
+
.filter_map(
|
|
377
|
+
|export| match self.sources.resolve(library, &export.uri, true) {
|
|
378
|
+
Target::Outside(path) => Some(path),
|
|
379
|
+
Target::Local | Target::Unknown => None,
|
|
380
|
+
},
|
|
381
|
+
)
|
|
382
|
+
.collect::<Vec<_>>();
|
|
383
|
+
self.prefetch(&targets, name);
|
|
384
|
+
let mut groups = BTreeMap::<(usize, usize), Vec<&crate::DartExport>>::new();
|
|
385
|
+
for export in &file.exports {
|
|
386
|
+
groups
|
|
387
|
+
.entry((export.location.line, export.location.column))
|
|
388
|
+
.or_default()
|
|
389
|
+
.push(export);
|
|
390
|
+
}
|
|
391
|
+
for branches in groups.into_values() {
|
|
392
|
+
let results = branches
|
|
393
|
+
.iter()
|
|
394
|
+
.map(|export| {
|
|
395
|
+
if !visible_through_combinators(name, &export.combinators) {
|
|
396
|
+
return Walk::empty();
|
|
397
|
+
}
|
|
398
|
+
match self.sources.resolve(library, &export.uri, true) {
|
|
399
|
+
Target::Outside(path) => self.export_walk(&path, name, visited),
|
|
400
|
+
Target::Local => Walk::empty(),
|
|
401
|
+
Target::Unknown => self.gap(),
|
|
402
|
+
}
|
|
403
|
+
})
|
|
404
|
+
.collect::<Vec<_>>();
|
|
405
|
+
let (classes, complete) = agree(&results);
|
|
406
|
+
walk.classes.extend(classes);
|
|
407
|
+
walk.complete &= complete;
|
|
408
|
+
}
|
|
409
|
+
walk
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
fn library_classes(&mut self, library: &Path, name: &str) -> Walk {
|
|
413
|
+
let file = match self.load(library, name) {
|
|
414
|
+
Outline::Read(file) => file,
|
|
415
|
+
Outline::Skipped => return Walk::empty(),
|
|
416
|
+
Outline::Missing | Outline::Unparsed => {
|
|
417
|
+
self.sources.note_gap(Some(library));
|
|
418
|
+
return Walk::unread();
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
self.library_of
|
|
422
|
+
.insert(library.to_path_buf(), library.to_path_buf());
|
|
423
|
+
let mut walk = Walk::empty();
|
|
424
|
+
if declares(&file, name) {
|
|
425
|
+
walk.classes.insert(ClassKey {
|
|
426
|
+
path: library.to_path_buf(),
|
|
427
|
+
name: name.to_owned(),
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
let parts = file
|
|
431
|
+
.parts
|
|
432
|
+
.iter()
|
|
433
|
+
.filter_map(
|
|
434
|
+
|part| match self.sources.resolve(library, &part.uri, true) {
|
|
435
|
+
Target::Outside(path) => Some(path),
|
|
436
|
+
Target::Local | Target::Unknown => None,
|
|
437
|
+
},
|
|
438
|
+
)
|
|
439
|
+
.collect::<Vec<_>>();
|
|
440
|
+
self.prefetch(&parts, name);
|
|
441
|
+
for part in &file.parts {
|
|
442
|
+
let Target::Outside(path) = self.sources.resolve(library, &part.uri, true) else {
|
|
443
|
+
self.sources.note_gap(None);
|
|
444
|
+
walk.complete = false;
|
|
445
|
+
continue;
|
|
446
|
+
};
|
|
447
|
+
match self.load(&path, name) {
|
|
448
|
+
Outline::Read(part_file) => {
|
|
449
|
+
self.library_of.insert(path.clone(), library.to_path_buf());
|
|
450
|
+
if declares(&part_file, name) {
|
|
451
|
+
walk.classes.insert(ClassKey {
|
|
452
|
+
path,
|
|
453
|
+
name: name.to_owned(),
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
Outline::Skipped => {}
|
|
458
|
+
Outline::Missing if self.sources.is_sdk_source(&path) => {}
|
|
459
|
+
Outline::Missing | Outline::Unparsed => {
|
|
460
|
+
self.sources.note_gap(Some(&path));
|
|
461
|
+
walk.complete = false;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
walk
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
fn agree(results: &[Walk]) -> (BTreeSet<ClassKey>, bool) {
|
|
470
|
+
let complete = results.iter().all(|walk| walk.complete);
|
|
471
|
+
let Some(first) = results.first() else {
|
|
472
|
+
return (BTreeSet::new(), true);
|
|
473
|
+
};
|
|
474
|
+
if results.iter().all(|walk| walk.classes == first.classes) {
|
|
475
|
+
(first.classes.clone(), complete)
|
|
476
|
+
} else {
|
|
477
|
+
(BTreeSet::new(), false)
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
fn exactly_one(mut classes: BTreeSet<ClassKey>) -> Option<ClassKey> {
|
|
482
|
+
let class = classes.pop_first()?;
|
|
483
|
+
classes.is_empty().then_some(class)
|
|
484
|
+
}
|