(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra)
| 314 | // --- createNode ------------------------------------------------------------ |
| 315 | |
| 316 | fn create_node(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra) -> Option<u32> { |
| 317 | if name.is_empty() { |
| 318 | return None; |
| 319 | } |
| 320 | let start_line = self.line_of(node); |
| 321 | let column = self.col_of(node); |
| 322 | let id = self.node_id_allocator.generate(self.file_path, kind, name, start_line, column); |
| 323 | let end_line = node.end_position().row as u32 + 1; // no resolveBody for php |
| 324 | |
| 325 | let qualified = { |
| 326 | let mut parts: Vec<&str> = Vec::new(); |
| 327 | for s in &self.stack { |
| 328 | if s.kind != "file" { |
| 329 | parts.push(&s.name); |
| 330 | } |
| 331 | } |
| 332 | let mut qn = parts.join("::"); |
| 333 | if !qn.is_empty() { |
| 334 | qn.push_str("::"); |
| 335 | } |
| 336 | qn.push_str(name); |
| 337 | qn |
| 338 | }; |
| 339 | |
| 340 | let mut flags = BoolFlags::default(); |
| 341 | if let Some(v) = extra.is_static { |
| 342 | flags.set(FLAG_IS_STATIC, v); |
| 343 | } |
| 344 | let name_ref = self.arena.put(name); |
| 345 | let qn_ref = self.arena.put(&qualified); |
| 346 | let id_ref = self.arena.put(&id); |
| 347 | let doc_ref = opt_str(&mut self.arena, extra.docstring.as_deref()); |
| 348 | let sig_ref = opt_str(&mut self.arena, extra.signature.as_deref()); |
| 349 | let ret_ref = opt_str(&mut self.arena, extra.return_type.as_deref()); |
| 350 | let row = self.tables.push_node(&NodeRow { |
| 351 | kind: node_kind_index(kind).unwrap(), |
| 352 | visibility: extra.visibility.unwrap_or(0), |
| 353 | flags, |
| 354 | start_line, |
| 355 | end_line, |
| 356 | start_column: self.col_of(node), |
| 357 | end_column: self.end_col_of(node), |
| 358 | name: name_ref, |
| 359 | qualified_name: qn_ref, |
| 360 | id: id_ref, |
| 361 | docstring: doc_ref, |
| 362 | signature: sig_ref, |
| 363 | decorators: NONE_STR, // php attributes never emit decorates refs |
| 364 | type_parameters: NONE_STR, |
| 365 | return_type: ret_ref, |
| 366 | extra_json: NONE_STR, |
| 367 | }); |
| 368 | self.node_ids.push(id); |
| 369 | |
| 370 | let parent_row = self.top_row(); |
| 371 | self.tables.push_edge(&EdgeRow { |
| 372 | source_idx: parent_row, |
| 373 | target_idx: row, |
no test coverage detected