(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra)
| 399 | // --- createNode ------------------------------------------------------------ |
| 400 | |
| 401 | fn create_node(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra) -> Option<u32> { |
| 402 | if name.is_empty() { |
| 403 | return None; |
| 404 | } |
| 405 | let start_line = self.line_of(node); |
| 406 | let column = self.col_of(node); |
| 407 | let id = self.node_id_allocator.generate(self.file_path, kind, name, start_line, column); |
| 408 | let end_line = node.end_position().row as u32 + 1; // no resolveBody for swift |
| 409 | |
| 410 | let qualified = { |
| 411 | let mut parts: Vec<&str> = Vec::new(); |
| 412 | for s in &self.stack { |
| 413 | if s.kind != "file" { |
| 414 | parts.push(&s.name); |
| 415 | } |
| 416 | } |
| 417 | let mut qn = parts.join("::"); |
| 418 | if !qn.is_empty() { |
| 419 | qn.push_str("::"); |
| 420 | } |
| 421 | qn.push_str(name); |
| 422 | qn |
| 423 | }; |
| 424 | |
| 425 | let mut flags = BoolFlags::default(); |
| 426 | if let Some(v) = extra.is_exported { |
| 427 | flags.set(FLAG_IS_EXPORTED, v); |
| 428 | } |
| 429 | if let Some(v) = extra.is_async { |
| 430 | flags.set(FLAG_IS_ASYNC, v); |
| 431 | } |
| 432 | if let Some(v) = extra.is_static { |
| 433 | flags.set(FLAG_IS_STATIC, v); |
| 434 | } |
| 435 | let name_ref = self.arena.put(name); |
| 436 | let qn_ref = self.arena.put(&qualified); |
| 437 | let id_ref = self.arena.put(&id); |
| 438 | let doc_ref = opt_str(&mut self.arena, extra.docstring.as_deref()); |
| 439 | let sig_ref = opt_str(&mut self.arena, extra.signature.as_deref()); |
| 440 | let ret_ref = opt_str(&mut self.arena, extra.return_type.as_deref()); |
| 441 | let row = self.tables.push_node(&NodeRow { |
| 442 | kind: node_kind_index(kind).unwrap(), |
| 443 | visibility: extra.visibility.unwrap_or(0), |
| 444 | flags, |
| 445 | start_line, |
| 446 | end_line, |
| 447 | start_column: self.col_of(node), |
| 448 | end_column: self.end_col_of(node), |
| 449 | name: name_ref, |
| 450 | qualified_name: qn_ref, |
| 451 | id: id_ref, |
| 452 | docstring: doc_ref, |
| 453 | signature: sig_ref, |
| 454 | decorators: NONE_STR, // extractModifiers absent — never set from modifiers |
| 455 | type_parameters: NONE_STR, |
| 456 | return_type: ret_ref, |
| 457 | extra_json: NONE_STR, |
| 458 | }); |
no test coverage detected