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

Method impl_item_owner

codegraph-kernel/src/rustlang.rs:452–464  ·  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

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

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