recoverCppMacroDefinedName (languages/c-cpp.ts:49).
(&self, node: Node)
| 644 | |
| 645 | /// recoverCppMacroDefinedName (languages/c-cpp.ts:49). |
| 646 | fn recover_cpp_macro_defined_name(&self, node: Node) -> Option<String> { |
| 647 | if node.kind() != "function_definition" { |
| 648 | return None; |
| 649 | } |
| 650 | let declarator = node.child_by_field_name("declarator")?; |
| 651 | if declarator.kind() != "function_declarator" { |
| 652 | return None; |
| 653 | } |
| 654 | let inner = declarator.child_by_field_name("declarator")?; |
| 655 | if inner.kind() != "identifier" { |
| 656 | return None; |
| 657 | } |
| 658 | let macro_name = self.text(inner); |
| 659 | if !macro_shaped_re().is_match(macro_name) { |
| 660 | return None; |
| 661 | } |
| 662 | let params = declarator.child_by_field_name("parameters")?; |
| 663 | if params.named_child_count() < 2 { |
| 664 | return None; |
| 665 | } |
| 666 | let lone_ident_text = |p: Node| -> Option<&'t str> { |
| 667 | if p.kind() == "parameter_declaration" |
| 668 | && p.named_child_count() == 1 |
| 669 | && p.named_child(0).map(|c| c.kind() == "type_identifier").unwrap_or(false) |
| 670 | { |
| 671 | Some(self.text(p.named_child(0).unwrap())) |
| 672 | } else { |
| 673 | None |
| 674 | } |
| 675 | }; |
| 676 | let name = params.named_child(0).and_then(lone_ident_text)?; |
| 677 | if !has_lower_re().is_match(name) { |
| 678 | return None; |
| 679 | } |
| 680 | for i in 1..params.named_child_count() { |
| 681 | if let Some(p) = params.named_child(i) { |
| 682 | if lone_ident_text(p).is_some() { |
| 683 | return None; |
| 684 | } |
| 685 | } |
| 686 | } |
| 687 | Some(name.to_string()) |
| 688 | } |
| 689 | |
| 690 | /// extractCppReceiverType (languages/c-cpp.ts:86). |
| 691 | fn receiver_type_of(&self, node: Node) -> Option<String> { |
no test coverage detected