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

Function defining_declaration

codegraph-kernel/src/ccpp/mod.rs:2707–2714  ·  view source on GitHub ↗

definingDeclaration (languages/c-cpp.ts): the `declaration` a class-like definition is the type of (`struct Foo { … } foo;`). Its comment documents the type, and an unnamed type takes the name of its first variable.

(node: Node)

Source from the content-addressed store, hash-verified

2705/// definition is the type of (`struct Foo { … } foo;`). Its comment documents
2706/// the type, and an unnamed type takes the name of its first variable.
2707fn defining_declaration(node: Node) -> Option<Node> {
2708 if !is_class_like_definition(node) {
2709 return None;
2710 }
2711 let parent = node.parent()?;
2712 let is_type = parent.child_by_field_name("type").map(|t| t.id()) == Some(node.id());
2713 (parent.kind() == "declaration" && is_type).then_some(parent)
2714}
2715
2716/// isMacroMisparsedTypeDecl (languages/c-cpp.ts:261): `class MACRO Name {…}`
2717/// misparse residue — bodyless class/struct specifier in `type` + a

Callers 2

class_like_docstringMethod · 0.85

Calls 3

is_class_like_definitionFunction · 0.85
mapMethod · 0.80
idMethod · 0.80

Tested by

no test coverage detected