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

Method create_node

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

Source from the content-addressed store, hash-verified

402 // --- createNode ------------------------------------------------------------
403
404 fn create_node(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra) -> Option<u32> {
405 if name.is_empty() {
406 return None;
407 }
408 let start_line = self.line_of(node);
409 let column = self.col_of(node);
410 let id = self.node_id_allocator.generate(self.file_path, kind, name, start_line, column);
411 // endLine extension via resolveBody — LIVE for kotlin function/method
412 // kinds (in-range for this grammar, so practically a no-op — but the
413 // hook is part of the contract).
414 let mut end_line = node.end_position().row as u32 + 1;
415 if kind == "function" || kind == "method" {
416 if let Some(body) = self.resolve_body(node) {
417 let be = body.end_position().row as u32 + 1;
418 if be > end_line {
419 end_line = be;
420 }
421 }
422 }
423
424 let qualified = match &extra.qualified_override {
425 Some(qn) => qn.clone(),
426 None => {
427 let mut parts: Vec<&str> = Vec::new();
428 for s in &self.stack {
429 if s.kind != "file" {
430 parts.push(&s.name);
431 }
432 }
433 let mut qn = parts.join("::");
434 if !qn.is_empty() {
435 qn.push_str("::");
436 }
437 qn.push_str(name);
438 qn
439 }
440 };
441
442 let mut flags = BoolFlags::default();
443 if let Some(v) = extra.is_async {
444 flags.set(FLAG_IS_ASYNC, v);
445 }
446 if let Some(v) = extra.is_static {
447 flags.set(FLAG_IS_STATIC, v);
448 }
449 // extractModifiers merge (tree-sitter.ts:1355) — runs for EVERY
450 // created node: expect/actual platform modifiers → decorators.
451 let mods = self.extract_modifiers(node);
452 let dec_ref: StrRef = match &mods {
453 Some(list) if !list.is_empty() => self.arena.put_list(list),
454 _ => NONE_STR,
455 };
456 let name_ref = self.arena.put(name);
457 let qn_ref = self.arena.put(&qualified);
458 let id_ref = self.arena.put(&id);
459 let doc_ref = opt_str(&mut self.arena, extra.docstring.as_deref());
460 let sig_ref = opt_str(&mut self.arena, extra.signature.as_deref());
461 let ret_ref = opt_str(&mut self.arena, extra.return_type.as_deref());

Callers 11

extractFunction · 0.45
try_visit_hookMethod · 0.45
extract_functionMethod · 0.45
extract_methodMethod · 0.45
extract_classMethod · 0.45
extract_interfaceMethod · 0.45
extract_enumMethod · 0.45
extract_enum_membersMethod · 0.45
extract_type_aliasMethod · 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
extract_modifiersMethod · 0.80
put_listMethod · 0.80
push_nodeMethod · 0.80
push_edgeMethod · 0.80
mapMethod · 0.80
opt_strFunction · 0.70
putMethod · 0.65
unwrapMethod · 0.60

Tested by

no test coverage detected