| 637 | } |
| 638 | |
| 639 | fn modifier(node: Node<'_>, source: &str, expected: &str) -> bool { |
| 640 | let mut stack: Vec<_> = named(node) |
| 641 | .into_iter() |
| 642 | .filter(|child| { |
| 643 | matches!( |
| 644 | child.kind(), |
| 645 | "modifiers" |
| 646 | | "visibility_modifier" |
| 647 | | "accessibility_modifier" |
| 648 | | "storage_class_specifier" |
| 649 | ) |
| 650 | }) |
| 651 | .collect(); |
| 652 | while let Some(item) = stack.pop() { |
| 653 | if item.kind() == "visibility_modifier" && expected == "pub" { |
| 654 | if text(item, source).trim() == "pub" { |
| 655 | return true; |
| 656 | } |
| 657 | continue; |
| 658 | } |
| 659 | if matches!( |
| 660 | item.kind(), |
| 661 | "annotation" | "marker_annotation" | "attribute" | "decorator" |
| 662 | ) || literal(item) |
| 663 | { |
| 664 | continue; |
| 665 | } |
| 666 | if text(item, source).trim() == expected { |
| 667 | return true; |
| 668 | } |
| 669 | stack.extend(children(item)); |
| 670 | } |
| 671 | false |
| 672 | } |
| 673 | |
| 674 | fn in_function(mut node: Node<'_>, language: Language) -> bool { |
| 675 | while let Some(parent) = node.parent() { |