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

Method from_sources

atomic-repository/src/repository/syntax_index.rs:34–118  ·  view source on GitHub ↗
(sources: &[(String, String)])

Source from the content-addressed store, hash-verified

32
33impl SyntaxIndex {
34 pub fn from_sources(sources: &[(String, String)]) -> Self {
35 let mut parser = ParserRegistry::new();
36 let mut index = Self::default();
37 let mut parsed = Vec::new();
38 let mut paths = BTreeSet::new();
39 for (path, source) in sources {
40 if crate::is_vault_path(path) {
41 continue;
42 }
43 paths.insert(path.clone());
44 index.file_modules.insert(
45 path.clone(),
46 Path::new(path)
47 .parent()
48 .and_then(|p| p.to_str())
49 .unwrap_or_default()
50 .to_owned(),
51 );
52 match parser.analyze_source(path, source) {
53 Ok(file) => {
54 index.entities.extend(file.entities.clone());
55 parsed.push(file);
56 }
57 Err(_) => index.entities.extend(parser.extract(path, source)),
58 }
59 }
60 let graph = SourceGraph::new(parsed, paths, true);
61 for symbol in graph
62 .symbols
63 .values()
64 .filter(|symbol| callable(&symbol.entity))
65 {
66 for alias in [
67 symbol.id.clone(),
68 selector(&symbol.entity),
69 symbol.entity.name.clone(),
70 ] {
71 index
72 .aliases
73 .entry(alias)
74 .or_default()
75 .insert(symbol.id.clone());
76 }
77 }
78 for call in graph
79 .bind_calls(None)
80 .into_iter()
81 .filter(|call| call.present && call.accessible)
82 {
83 let caller = &graph.symbols[&call.call.caller];
84 index
85 .calls
86 .insert((call.symbol.id.clone(), caller.id.clone()));
87 index
88 .bound_callers
89 .entry(call.symbol.id.clone())
90 .or_default()
91 .push(Caller {

Callers

nothing calls this directly

Calls 14

selectorFunction · 0.85
script_candidatesFunction · 0.85
parentMethod · 0.80
analyze_sourceMethod · 0.80
extendMethod · 0.80
bind_callsMethod · 0.80
callableFunction · 0.70
is_vault_pathFunction · 0.50
insertMethod · 0.45
cloneMethod · 0.45
pushMethod · 0.45
extractMethod · 0.45

Tested by

no test coverage detected