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)
| 1704 | /// `value` — an expression body's `=> …` or an `= initializer`. Attributes |
| 1705 | /// are not walked. |
| 1706 | fn property_bodies(node: Node) -> Vec<Node> { |
| 1707 | let mut bodies = Vec::new(); |
| 1708 | if let Some(accessors) = node.child_by_field_name("accessors") { |
| 1709 | for i in 0..accessors.named_child_count() { |
| 1710 | let Some(accessor) = accessors.named_child(i) else { continue }; |
| 1711 | if accessor.kind() != "accessor_declaration" { |
| 1712 | continue; |
| 1713 | } |
| 1714 | if let Some(body) = accessor.child_by_field_name("body") { |
| 1715 | bodies.push(body); |
| 1716 | } |
| 1717 | } |
| 1718 | } |
| 1719 | if let Some(value) = node.child_by_field_name("value") { |
| 1720 | bodies.push(value); |
| 1721 | } |
| 1722 | bodies |
| 1723 | } |
| 1724 | |
| 1725 | fn last_named_child(node: Node) -> Option<Node> { |
| 1726 | node.named_child(node.named_child_count().checked_sub(1)?) |