(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra)
| 258 | } |
| 259 | |
| 260 | fn create_node(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra) -> Option<u32> { |
| 261 | if name.is_empty() { |
| 262 | return None; |
| 263 | } |
| 264 | let start_line = self.line_of(node); |
| 265 | let column = self.col_of(node); |
| 266 | let id = self.node_id_allocator.generate(self.file_path, kind, name, start_line, column); |
| 267 | let end_line = node.end_position().row as u32 + 1; |
| 268 | |
| 269 | let qualified = extra.qualified_name.unwrap_or_else(|| { |
| 270 | let mut parts: Vec<&str> = Vec::new(); |
| 271 | for s in &self.stack { |
| 272 | if s.kind != "file" { |
| 273 | parts.push(&s.name); |
| 274 | } |
| 275 | } |
| 276 | let mut qn = parts.join("::"); |
| 277 | if !qn.is_empty() { |
| 278 | qn.push_str("::"); |
| 279 | } |
| 280 | qn.push_str(name); |
| 281 | qn |
| 282 | }); |
| 283 | |
| 284 | let mut flags = BoolFlags::default(); |
| 285 | if let Some(v) = extra.is_exported { |
| 286 | flags.set(FLAG_IS_EXPORTED, v); |
| 287 | } |
| 288 | if let Some(v) = extra.is_async { |
| 289 | flags.set(FLAG_IS_ASYNC, v); |
| 290 | } |
| 291 | let name_ref = self.arena.put(name); |
| 292 | let qn_ref = self.arena.put(&qualified); |
| 293 | let id_ref = self.arena.put(&id); |
| 294 | let doc_ref = opt_str(&mut self.arena, extra.docstring.as_deref()); |
| 295 | let sig_ref = opt_str(&mut self.arena, extra.signature.as_deref()); |
| 296 | let decorators_ref = opt_str(&mut self.arena, extra.decorators.as_deref()); |
| 297 | let ret_ref = opt_str(&mut self.arena, extra.return_type.as_deref()); |
| 298 | let row = self.tables.push_node(&NodeRow { |
| 299 | kind: node_kind_index(kind).unwrap(), |
| 300 | visibility: extra.visibility.unwrap_or(0), |
| 301 | flags, |
| 302 | start_line, |
| 303 | end_line, |
| 304 | start_column: self.col_of(node), |
| 305 | end_column: self.end_col_of(node), |
| 306 | name: name_ref, |
| 307 | qualified_name: qn_ref, |
| 308 | id: id_ref, |
| 309 | docstring: doc_ref, |
| 310 | signature: sig_ref, |
| 311 | decorators: decorators_ref, |
| 312 | type_parameters: NONE_STR, |
| 313 | return_type: ret_ref, |
| 314 | extra_json: NONE_STR, |
| 315 | }); |
| 316 | self.nodes_meta.push(NodeMeta { kind, name: name.to_string() }); |
| 317 | self.node_ids.push(id); |
no test coverage detected