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

Method create_node

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

Source from the content-addressed store, hash-verified

398 // --- createNode ------------------------------------------------------------
399
400 fn create_node(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra) -> Option<u32> {
401 if name.is_empty() {
402 return None;
403 }
404 let start_line = self.line_of(node);
405 let column = self.col_of(node);
406 let id = self.node_id_allocator.generate(self.file_path, kind, name, start_line, column);
407 let end_line = node.end_position().row as u32 + 1; // no resolveBody for swift
408
409 let qualified = {
410 let mut parts: Vec<&str> = Vec::new();
411 for s in &self.stack {
412 if s.kind != "file" {
413 parts.push(&s.name);
414 }
415 }
416 let mut qn = parts.join("::");
417 if !qn.is_empty() {
418 qn.push_str("::");
419 }
420 qn.push_str(name);
421 qn
422 };
423
424 let mut flags = BoolFlags::default();
425 if let Some(v) = extra.is_exported {
426 flags.set(FLAG_IS_EXPORTED, v);
427 }
428 if let Some(v) = extra.is_async {
429 flags.set(FLAG_IS_ASYNC, v);
430 }
431 if let Some(v) = extra.is_static {
432 flags.set(FLAG_IS_STATIC, v);
433 }
434 let name_ref = self.arena.put(name);
435 let qn_ref = self.arena.put(&qualified);
436 let id_ref = self.arena.put(&id);
437 let doc_ref = opt_str(&mut self.arena, extra.docstring.as_deref());
438 let sig_ref = opt_str(&mut self.arena, extra.signature.as_deref());
439 let ret_ref = opt_str(&mut self.arena, extra.return_type.as_deref());
440 let row = self.tables.push_node(&NodeRow {
441 kind: node_kind_index(kind).unwrap(),
442 visibility: extra.visibility.unwrap_or(0),
443 flags,
444 start_line,
445 end_line,
446 start_column: self.col_of(node),
447 end_column: self.end_col_of(node),
448 name: name_ref,
449 qualified_name: qn_ref,
450 id: id_ref,
451 docstring: doc_ref,
452 signature: sig_ref,
453 decorators: NONE_STR, // extractModifiers absent — never set from modifiers
454 type_parameters: NONE_STR,
455 return_type: ret_ref,
456 extra_json: NONE_STR,
457 });

Callers 11

extract_functionMethod · 0.45
extract_methodMethod · 0.45
extract_classMethod · 0.45
extract_structMethod · 0.45
extract_enumMethod · 0.45
extract_enum_membersMethod · 0.45
extract_interfaceMethod · 0.45
extract_type_aliasMethod · 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