(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra)
| 253 | // --- createNode ------------------------------------------------------------ |
| 254 | |
| 255 | fn create_node(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra) -> Option<u32> { |
| 256 | if name.is_empty() { |
| 257 | return None; |
| 258 | } |
| 259 | let start_line = self.line_of(node); |
| 260 | let id = ids::node_id(self.file_path, kind, name, start_line); |
| 261 | let end_line = node.end_position().row as u32 + 1; // no resolveBody for ruby |
| 262 | |
| 263 | let qualified = { |
| 264 | let mut parts: Vec<&str> = Vec::new(); |
| 265 | for s in &self.stack { |
| 266 | if s.kind != "file" { |
| 267 | parts.push(&s.name); |
| 268 | } |
| 269 | } |
| 270 | let mut qn = parts.join("::"); |
| 271 | if !qn.is_empty() { |
| 272 | qn.push_str("::"); |
| 273 | } |
| 274 | qn.push_str(name); |
| 275 | qn |
| 276 | }; |
| 277 | |
| 278 | let name_ref = self.arena.put(name); |
| 279 | let qn_ref = self.arena.put(&qualified); |
| 280 | let id_ref = self.arena.put(&id); |
| 281 | let doc_ref = opt_str(&mut self.arena, extra.docstring.as_deref()); |
| 282 | let sig_ref = opt_str(&mut self.arena, extra.signature.as_deref()); |
| 283 | let row = self.tables.push_node(&NodeRow { |
| 284 | kind: node_kind_index(kind).unwrap(), |
| 285 | visibility: extra.visibility.unwrap_or(0), |
| 286 | flags: BoolFlags::default(), // no isExported/isAsync/isStatic hooks |
| 287 | start_line, |
| 288 | end_line, |
| 289 | start_column: self.col_of(node), |
| 290 | end_column: self.end_col_of(node), |
| 291 | name: name_ref, |
| 292 | qualified_name: qn_ref, |
| 293 | id: id_ref, |
| 294 | docstring: doc_ref, |
| 295 | signature: sig_ref, |
| 296 | decorators: NONE_STR, // ruby has no decorator node kinds — always a no-op |
| 297 | type_parameters: NONE_STR, |
| 298 | return_type: NONE_STR, |
| 299 | extra_json: NONE_STR, |
| 300 | }); |
| 301 | self.node_ids.push(id); |
| 302 | |
| 303 | let parent_row = self.top_row(); |
| 304 | self.tables.push_edge(&EdgeRow { |
| 305 | source_idx: parent_row, |
| 306 | target_idx: row, |
| 307 | kind: edge_kind_index("contains").unwrap(), |
| 308 | provenance: 0, |
| 309 | line: NONE, |
| 310 | column: NONE, |
| 311 | metadata_json: NONE_STR, |
| 312 | source_id_str: NONE_STR, |
no test coverage detected