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

Method create_node

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

Source from the content-addressed store, hash-verified

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