propertyBodies (tree-sitter.ts) — the parts of a property that run code: each accessor's `body` (a block or `=> expr`), then the property's `value` — an expression body's `=> …` or an `= initializer`. Attributes are not walked.
(node: Node)
| 1732 | /// `value` — an expression body's `=> …` or an `= initializer`. Attributes |
| 1733 | /// are not walked. |
| 1734 | fn property_bodies(node: Node) -> Vec<Node> { |
| 1735 | let mut bodies = Vec::new(); |
| 1736 | if let Some(accessors) = node.child_by_field_name("accessors") { |
| 1737 | for i in 0..accessors.named_child_count() { |
| 1738 | let Some(accessor) = accessors.named_child(i) else { continue }; |
| 1739 | if accessor.kind() != "accessor_declaration" { |
| 1740 | continue; |
| 1741 | } |
| 1742 | if let Some(body) = accessor.child_by_field_name("body") { |
| 1743 | bodies.push(body); |
| 1744 | } |
| 1745 | } |
| 1746 | } |
| 1747 | if let Some(value) = node.child_by_field_name("value") { |
| 1748 | bodies.push(value); |
| 1749 | } |
| 1750 | bodies |
| 1751 | } |
| 1752 | |
| 1753 | fn last_named_child(node: Node) -> Option<Node> { |
| 1754 | node.named_child(node.named_child_count().checked_sub(1)?) |