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

Function defining_declaration

codegraph-kernel/src/ccpp/mod.rs:2705–2712  ·  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

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