`holders` are the members between the owner and `obj` that have no node yet, outermost first: each holds the literal the next is written in. The first documented member found under them gives them their nodes, in that order, and puts them on the stack; a branch with nothing documented in it leaves no node behind. `list` takes the name of every member, in source order, with `{` and `}` around the
(
&mut self,
obj: Node<'t>,
depth: usize,
holders: &mut Vec<DataMemberHolder<'t>>,
list: &mut Option<ObjectMemberList>,
)
| 1181 | /// `}` around the members of a nested literal and `#` before one that has |
| 1182 | /// a node; None when the owner lists none. |
| 1183 | fn walk_object_data_members( |
| 1184 | &mut self, |
| 1185 | obj: Node<'t>, |
| 1186 | depth: usize, |
| 1187 | holders: &mut Vec<DataMemberHolder<'t>>, |
| 1188 | list: &mut Option<ObjectMemberList>, |
| 1189 | ) { |
| 1190 | // A listed literal has every member visited, a hundred thousand of |
| 1191 | // them in a table of data: each is asked for its kind once, for its key |
| 1192 | // and value by the fields' ids, and nothing of it is copied. |
| 1193 | let (key_field, value_field) = *self.pair_fields.get_or_init(|| { |
| 1194 | let language = obj.language(); |
| 1195 | let id = |name: &str| language.field_id_for_name(name).map_or(0, std::num::NonZeroU16::get); |
| 1196 | (id("key"), id("value")) |
| 1197 | }); |
| 1198 | let mut cursor = obj.walk(); |
| 1199 | // Whether the named child before this one is a comment: what |
| 1200 | // prev_named_sibling would say, kept from the pass itself. |
| 1201 | let mut under_comment = false; |
| 1202 | for member in obj.named_children(&mut cursor) { |
| 1203 | let commented = under_comment; |
| 1204 | let member_kind = member.kind(); |
| 1205 | under_comment = member_kind == "comment"; |
| 1206 | if member_kind != "pair" { |
| 1207 | continue; |
| 1208 | } |
| 1209 | // Neither a comment above it nor room for one inside it: a plain |
| 1210 | // value, or a literal of them. Nothing here can have a node, so |
| 1211 | // where nothing is listed either it is left. |
| 1212 | if list.is_none() && !commented && !self.may_hold_comment(member.start_byte(), member.end_byte()) { |
| 1213 | continue; |
| 1214 | } |
| 1215 | let Some(key) = member.child_by_field_id(key_field) else { continue }; |
| 1216 | if !matches!(key.kind(), "property_identifier" | "string") { |
| 1217 | continue; |
| 1218 | } |
| 1219 | let value = member.child_by_field_id(value_field); |
| 1220 | let value_kind = value.map_or("", |v| v.kind()); |
| 1221 | // A function member is the owner's `function` node already (owned_member_function). |
| 1222 | if is_object_member_function(value_kind) { |
| 1223 | continue; |
| 1224 | } |
| 1225 | let name = object_key_name_of(self.text(key)); |
| 1226 | if !is_data_member_name(name) { |
| 1227 | continue; |
| 1228 | } |
| 1229 | let nested = if depth < OBJECT_DATA_MEMBER_MAX_DEPTH && matches!(value_kind, "object" | "object_expression" | "as_expression" | "satisfies_expression" | "parenthesized_expression") { |
| 1230 | self.object_literal_of(value) |
| 1231 | } else { |
| 1232 | None |
| 1233 | }; |
| 1234 | // The comment above the member, never the one trailing the member before it. |
| 1235 | let docstring = if commented { |
| 1236 | crate::docstring::preceding_docstring_skipping_trailing(member, self.src) |
| 1237 | } else { |
| 1238 | None |
| 1239 | }; |
| 1240 | let mut held: Option<u32> = None; |
no test coverage detected