(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra)
| 225 | } |
| 226 | |
| 227 | fn create_node(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra) -> Option<u32> { |
| 228 | if name.is_empty() { |
| 229 | return None; |
| 230 | } |
| 231 | let start_line = self.line_of(node); |
| 232 | let column = self.col_of(node); |
| 233 | let id = self.node_id_allocator.generate(self.file_path, kind, name, start_line, column); |
| 234 | let end_line = node.end_position().row as u32 + 1; |
| 235 | |
| 236 | let qualified = extra.qualified_name.unwrap_or_else(|| { |
| 237 | let mut parts: Vec<&str> = Vec::new(); |
| 238 | for s in &self.stack { |
| 239 | if s.kind != "file" { |
| 240 | parts.push(&s.name); |
| 241 | } |
| 242 | } |
| 243 | let mut qn = parts.join("::"); |
| 244 | if !qn.is_empty() { |
| 245 | qn.push_str("::"); |
| 246 | } |
| 247 | qn.push_str(name); |
| 248 | qn |
| 249 | }); |
| 250 | |
| 251 | let mut flags = BoolFlags::default(); |
| 252 | if let Some(v) = extra.is_exported { |
| 253 | flags.set(FLAG_IS_EXPORTED, v); |
| 254 | } |
| 255 | let name_ref = self.arena.put(name); |
| 256 | let qn_ref = self.arena.put(&qualified); |
| 257 | let id_ref = self.arena.put(&id); |
| 258 | let doc_ref = opt_str(&mut self.arena, extra.docstring.as_deref()); |
| 259 | let sig_ref = opt_str(&mut self.arena, extra.signature.as_deref()); |
| 260 | let ret_ref = opt_str(&mut self.arena, extra.return_type.as_deref()); |
| 261 | let row = self.tables.push_node(&NodeRow { |
| 262 | kind: node_kind_index(kind).unwrap(), |
| 263 | visibility: 0, |
| 264 | flags, |
| 265 | start_line, |
| 266 | end_line, |
| 267 | start_column: self.col_of(node), |
| 268 | end_column: self.end_col_of(node), |
| 269 | name: name_ref, |
| 270 | qualified_name: qn_ref, |
| 271 | id: id_ref, |
| 272 | docstring: doc_ref, |
| 273 | signature: sig_ref, |
| 274 | decorators: NONE_STR, |
| 275 | type_parameters: NONE_STR, |
| 276 | return_type: ret_ref, |
| 277 | extra_json: NONE_STR, |
| 278 | }); |
| 279 | self.nodes_meta.push(NodeMeta { kind, name: name.to_string() }); |
| 280 | self.node_ids.push(id); |
| 281 | |
| 282 | let parent_row = self.top_row(); |
| 283 | self.tables.push_edge(&EdgeRow { |
| 284 | source_idx: parent_row, |
no test coverage detected