MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / lookup_in_manifest

Method lookup_in_manifest

compiler/src/main/resolver.rs:95–113  ·  view source on GitHub ↗
(&mut self, m_spec: &str, name: &str)

Source from the content-addressed store, hash-verified

93
94 #[allow(clippy::type_complexity)]
95 fn lookup_in_manifest(&mut self, m_spec: &str, name: &str) -> Result<Option<(Option<String>, Option<String>)>, String> {
96 if let Some(hit) = with_runtime(|rt| {
97 rt.manifests.iter()
98 .find(|(s, _)| s == m_spec)
99 .map(|(_, m)| (m.imports.iter().find(|(k, _)| k == name).map(|(_, v)| v.clone()), m.extends.clone()))
100 }) {
101 return Ok(Some(hit));
102 }
103 // Walk-up fetch, manifests aren't pinned by URL fragment, so no hash.
104 let bytes = match self.fetch_bytes(m_spec, None) {
105 Ok(b) => b,
106 Err(_) => return Ok(None),
107 };
108 let parsed = parse_manifest(&bytes).map_err(|e| s!("packages.json at '", str m_spec, "': ", str &e))?;
109 let target = parsed.imports.iter().find(|(k, _)| k == name).map(|(_, v)| v.clone());
110 let ext = parsed.extends.clone();
111 with_runtime(|rt| rt.manifests.push((m_spec.to_string(), parsed)));
112 Ok(Some((target, ext)))
113 }
114
115 fn resolve_canonical(&self, spec: &str) -> Result<Resolved, String> {
116 let entry = with_runtime(|rt| {

Callers 1

resolve_bareMethod · 0.80

Calls 5

with_runtimeFunction · 0.85
parse_manifestFunction · 0.85
pushMethod · 0.80
iterMethod · 0.45
fetch_bytesMethod · 0.45

Tested by

no test coverage detected