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