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

Method is_cpp_pure_virtual_method_decl

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

`#1727`: C++ pure-virtual method declaration (`virtual int read(int key) = 0;`). tree-sitter-cpp shapes these as `field_declaration` whose declarator unwraps to a `function_declarator`, with the pure-virtual `= 0` as a DIRECT `number_literal` "0" child (default-arg `= 0` lives inside `parameter_declaration` and must not match).

(&self, node: Node<'_>)

Source from the content-addressed store, hash-verified

1021 /// `number_literal` "0" child (default-arg `= 0` lives inside
1022 /// `parameter_declaration` and must not match).
1023 fn is_cpp_pure_virtual_method_decl(&self, node: Node<'_>) -> bool {
1024 if node.kind() != "field_declaration" {
1025 return false;
1026 }
1027 let Some(mut declarator) = node.child_by_field_name("declarator") else {
1028 return false;
1029 };
1030 while matches!(declarator.kind(), "pointer_declarator" | "reference_declarator") {
1031 let inner = declarator
1032 .child_by_field_name("declarator")
1033 .or_else(|| declarator.named_child(0));
1034 let Some(inner) = inner else {
1035 return false;
1036 };
1037 declarator = inner;
1038 }
1039 if declarator.kind() != "function_declarator" {
1040 return false;
1041 }
1042 (0..node.named_child_count())
1043 .filter_map(|i| node.named_child(i))
1044 .any(|c| c.kind() == "number_literal" && self.text(c) == "0")
1045 }
1046
1047
1048 /// cppExtractor.isMisparsedFunction (languages/c-cpp.ts:811). cpp only.

Callers 2

dispatch_nodeMethod · 0.80
extract_methodMethod · 0.80

Calls 1

textMethod · 0.65

Tested by

no test coverage detected