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

Method create_node

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

Source from the content-addressed store, hash-verified

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