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

Method create_node

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

Source from the content-addressed store, hash-verified

319 // --- createNode ------------------------------------------------------------
320
321 fn create_node(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra) -> Option<u32> {
322 if name.is_empty() {
323 return None;
324 }
325 let start_line = self.line_of(node);
326 let id = ids::node_id(self.file_path, kind, name, start_line);
327 // endLine extension via resolveBody — LIVE for kotlin function/method
328 // kinds (in-range for this grammar, so practically a no-op — but the
329 // hook is part of the contract).
330 let mut end_line = node.end_position().row as u32 + 1;
331 if kind == "function" || kind == "method" {
332 if let Some(body) = self.resolve_body(node) {
333 let be = body.end_position().row as u32 + 1;
334 if be > end_line {
335 end_line = be;
336 }
337 }
338 }
339
340 let qualified = match &extra.qualified_override {
341 Some(qn) => qn.clone(),
342 None => {
343 let mut parts: Vec<&str> = Vec::new();
344 for s in &self.stack {
345 if s.kind != "file" {
346 parts.push(&s.name);
347 }
348 }
349 let mut qn = parts.join("::");
350 if !qn.is_empty() {
351 qn.push_str("::");
352 }
353 qn.push_str(name);
354 qn
355 }
356 };
357
358 let mut flags = BoolFlags::default();
359 if let Some(v) = extra.is_async {
360 flags.set(FLAG_IS_ASYNC, v);
361 }
362 if let Some(v) = extra.is_static {
363 flags.set(FLAG_IS_STATIC, v);
364 }
365 // extractModifiers merge (tree-sitter.ts:1355) — runs for EVERY
366 // created node: expect/actual platform modifiers → decorators.
367 let mods = self.extract_modifiers(node);
368 let dec_ref: StrRef = match &mods {
369 Some(list) if !list.is_empty() => self.arena.put_list(list),
370 _ => NONE_STR,
371 };
372 let name_ref = self.arena.put(name);
373 let qn_ref = self.arena.put(&qualified);
374 let id_ref = self.arena.put(&id);
375 let doc_ref = opt_str(&mut self.arena, extra.docstring.as_deref());
376 let sig_ref = opt_str(&mut self.arena, extra.signature.as_deref());
377 let ret_ref = opt_str(&mut self.arena, extra.return_type.as_deref());
378 let row = self.tables.push_node(&NodeRow {

Callers 10

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_idFunction · 0.85
node_kind_indexFunction · 0.85
edge_kind_indexFunction · 0.85
utf16_lenFunction · 0.85
extract_modifiersMethod · 0.80
put_listMethod · 0.80
putMethod · 0.80
push_nodeMethod · 0.80
push_edgeMethod · 0.80
opt_strFunction · 0.70
unwrapMethod · 0.60
line_ofMethod · 0.45

Tested by

no test coverage detected