`#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<'_>)
| 1033 | /// `number_literal` "0" child (default-arg `= 0` lives inside |
| 1034 | /// `parameter_declaration` and must not match). |
| 1035 | fn is_cpp_pure_virtual_method_decl(&self, node: Node<'_>) -> bool { |
| 1036 | if node.kind() != "field_declaration" { |
| 1037 | return false; |
| 1038 | } |
| 1039 | let Some(mut declarator) = node.child_by_field_name("declarator") else { |
| 1040 | return false; |
| 1041 | }; |
| 1042 | while matches!(declarator.kind(), "pointer_declarator" | "reference_declarator") { |
| 1043 | let inner = declarator |
| 1044 | .child_by_field_name("declarator") |
| 1045 | .or_else(|| declarator.named_child(0)); |
| 1046 | let Some(inner) = inner else { |
| 1047 | return false; |
| 1048 | }; |
| 1049 | declarator = inner; |
| 1050 | } |
| 1051 | if declarator.kind() != "function_declarator" { |
| 1052 | return false; |
| 1053 | } |
| 1054 | (0..node.named_child_count()) |
| 1055 | .filter_map(|i| node.named_child(i)) |
| 1056 | .any(|c| c.kind() == "number_literal" && self.text(c) == "0") |
| 1057 | } |
| 1058 | |
| 1059 | |
| 1060 | /// cppExtractor.isMisparsedFunction (languages/c-cpp.ts:811). cpp only. |
no test coverage detected