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

Function candidate_path

atomic-repository/src/repository/semantic_review.rs:335–360  ·  view source on GitHub ↗
(path: &str, target: &Symbol)

Source from the content-addressed store, hash-verified

333}
334
335fn candidate_path(path: &str, target: &Symbol) -> bool {
336 if path == target.location.path || target.public {
337 return true;
338 }
339 if Language::detect(&target.location.path) != Some(Language::Rust) {
340 return false;
341 }
342 let file = std::path::Path::new(&target.location.path);
343 let mut region = file
344 .parent()
345 .unwrap_or_else(|| std::path::Path::new(""))
346 .to_path_buf();
347 if !matches!(
348 file.file_name().and_then(|name| name.to_str()),
349 Some("lib.rs" | "main.rs" | "mod.rs")
350 ) {
351 region.push(file.file_stem().unwrap_or_default());
352 }
353 for module in &target.module_scope {
354 region.push(module);
355 }
356 if target.parent_visible {
357 region.pop();
358 }
359 std::path::Path::new(path).starts_with(region)
360}

Callers 1

select_contextMethod · 0.85

Calls 2

parentMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected