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

Function rust_roots

atomic-audit/src/extract/languages.rs:477–498  ·  view source on GitHub ↗

Distinct explicit dependency units, not a type-resolved coupling metric.

(node: Node<'_>, source: &str, result: &mut BTreeSet<String>)

Source from the content-addressed store, hash-verified

475
476/// Distinct explicit dependency units, not a type-resolved coupling metric.
477fn rust_roots(node: Node<'_>, source: &str, result: &mut BTreeSet<String>) {
478 if node.kind() == "use_list" {
479 for child in named(node) {
480 rust_roots(child, source, result);
481 }
482 } else if node.kind() == "use_as_clause" {
483 if let Some(path) = node.child_by_field_name("path") {
484 rust_roots(path, source, result);
485 }
486 } else {
487 let path = node.child_by_field_name("path").unwrap_or(node);
488 let root = text(path, source)
489 .trim_start_matches("::")
490 .split("::")
491 .next()
492 .unwrap_or_default()
493 .trim();
494 if !root.is_empty() {
495 result.insert(root.into());
496 }
497 }
498}
499
500fn rust_bindings(node: Node<'_>, source: &str, prefix: Option<&str>, result: &mut Vec<String>) {
501 match node.kind() {

Callers 1

dependenciesFunction · 0.85

Calls 6

namedFunction · 0.70
textFunction · 0.70
kindMethod · 0.45
nextMethod · 0.45
is_emptyMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected