MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / impl_item_owner

Method impl_item_owner

codegraph-kernel/src/rustlang.rs:458–470  ·  view source on GitHub ↗

rustImplItemOwner (languages/rust.ts) — the type an item written directly in an impl block belongs to: `ValueHint` for the `type Err` of `impl FromStr for ValueHint`, then `ValueHint::Err`, as the impl's methods are. A type no single name stands for (`()`, `(A, B)`, `[u8]`, `u32`) is written as the impl writes it. Mirrored byte-for-byte — change both.

(&self, node: Node)

Source from the content-addressed store, hash-verified

456 /// `u32`) is written as the impl writes it. Mirrored byte-for-byte —
457 /// change both.
458 fn impl_item_owner(&self, node: Node) -> Option<String> {
459 let list = node.parent().filter(|p| p.kind() == "declaration_list")?;
460 let imp = list.parent().filter(|p| p.kind() == "impl_item")?;
461 let mut ty = imp.child_by_field_name("type")?;
462 while ty.kind() == "reference_type" {
463 ty = ty.child_by_field_name("type")?;
464 }
465 self.impl_type_name(Some(ty)).or_else(|| {
466 let words: Vec<&str> =
467 self.text(ty).split([' ', '\t', '\r', '\n']).filter(|w| !w.is_empty()).collect();
468 Some(words.join(" "))
469 })
470 }
471
472 // --- visitNode ------------------------------------------------------------
473

Callers 2

extract_type_aliasMethod · 0.80
extract_variableMethod · 0.80

Calls 4

impl_type_nameMethod · 0.80
textMethod · 0.65
collectMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected