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:1025–1047  ·  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

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