MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / create_node

Method create_node

codegraph-kernel/src/ruby.rs:273–363  ·  view source on GitHub ↗
(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra)

Source from the content-addressed store, hash-verified

271 // --- createNode ------------------------------------------------------------
272
273 fn create_node(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra) -> Option<u32> {
274 if name.is_empty() {
275 return None;
276 }
277 let start_line = self.line_of(node);
278 let column = self.col_of(node);
279 let id = self.node_id_allocator.generate(self.file_path, kind, name, start_line, column);
280 let end_line = node.end_position().row as u32 + 1; // no resolveBody for ruby
281
282 let qualified = {
283 let mut parts: Vec<&str> = Vec::new();
284 for s in &self.stack {
285 if s.kind != "file" {
286 parts.push(&s.name);
287 }
288 }
289 let mut qn = parts.join("::");
290 if !qn.is_empty() {
291 qn.push_str("::");
292 }
293 qn.push_str(name);
294 qn
295 };
296
297 let name_ref = self.arena.put(name);
298 let qn_ref = self.arena.put(&qualified);
299 let id_ref = self.arena.put(&id);
300 let doc_ref = opt_str(&mut self.arena, extra.docstring.as_deref());
301 let sig_ref = opt_str(&mut self.arena, extra.signature.as_deref());
302 // No isExported/isAsync hooks; isStatic only for defs.
303 let mut flags = BoolFlags::default();
304 if let Some(v) = extra.is_static {
305 flags.set(FLAG_IS_STATIC, v);
306 }
307 let row = self.tables.push_node(&NodeRow {
308 kind: node_kind_index(kind).unwrap(),
309 visibility: extra.visibility.unwrap_or(0),
310 flags,
311 start_line,
312 end_line,
313 start_column: self.col_of(node),
314 end_column: self.end_col_of(node),
315 name: name_ref,
316 qualified_name: qn_ref,
317 id: id_ref,
318 docstring: doc_ref,
319 signature: sig_ref,
320 decorators: NONE_STR, // ruby has no decorator node kinds — always a no-op
321 type_parameters: NONE_STR,
322 return_type: NONE_STR,
323 extra_json: NONE_STR,
324 });
325 self.node_ids.push(id);
326
327 let parent_row = self.top_row();
328 self.tables.push_edge(&EdgeRow {
329 source_idx: parent_row,
330 target_idx: row,

Callers 6

try_visit_hookMethod · 0.45
extract_functionMethod · 0.45
extract_methodMethod · 0.45
extract_classMethod · 0.45
extract_variableMethod · 0.45
extract_importMethod · 0.45

Calls 15

node_kind_indexFunction · 0.85
edge_kind_indexFunction · 0.85
utf16_lenFunction · 0.85
pushMethod · 0.80
push_nodeMethod · 0.80
push_edgeMethod · 0.80
mapMethod · 0.80
opt_strFunction · 0.70
putMethod · 0.65
unwrapMethod · 0.60
line_ofMethod · 0.45
col_ofMethod · 0.45

Tested by

no test coverage detected