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

Method create_node

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

Source from the content-addressed store, hash-verified

318 // --- createNode ------------------------------------------------------------
319
320 fn create_node(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra) -> Option<u32> {
321 if name.is_empty() {
322 return None;
323 }
324 let start_line = self.line_of(node);
325 let column = self.col_of(node);
326 let id = self.node_id_allocator.generate(self.file_path, kind, name, start_line, column);
327 let end_line = node.end_position().row as u32 + 1; // no resolveBody for php
328
329 let qualified = {
330 let mut parts: Vec<&str> = Vec::new();
331 for s in &self.stack {
332 if s.kind != "file" {
333 parts.push(&s.name);
334 }
335 }
336 let mut qn = parts.join("::");
337 if !qn.is_empty() {
338 qn.push_str("::");
339 }
340 qn.push_str(name);
341 qn
342 };
343
344 let mut flags = BoolFlags::default();
345 if let Some(v) = extra.is_static {
346 flags.set(FLAG_IS_STATIC, v);
347 }
348 let name_ref = self.arena.put(name);
349 let qn_ref = self.arena.put(&qualified);
350 let id_ref = self.arena.put(&id);
351 let doc_ref = opt_str(&mut self.arena, extra.docstring.as_deref());
352 let sig_ref = opt_str(&mut self.arena, extra.signature.as_deref());
353 let ret_ref = opt_str(&mut self.arena, extra.return_type.as_deref());
354 let row = self.tables.push_node(&NodeRow {
355 kind: node_kind_index(kind).unwrap(),
356 visibility: extra.visibility.unwrap_or(0),
357 flags,
358 start_line,
359 end_line,
360 start_column: self.col_of(node),
361 end_column: self.end_col_of(node),
362 name: name_ref,
363 qualified_name: qn_ref,
364 id: id_ref,
365 docstring: doc_ref,
366 signature: sig_ref,
367 decorators: NONE_STR, // php attributes never emit decorates refs
368 type_parameters: NONE_STR,
369 return_type: ret_ref,
370 extra_json: NONE_STR,
371 });
372 self.node_ids.push(id);
373
374 let parent_row = self.top_row();
375 self.tables.push_edge(&EdgeRow {
376 source_idx: parent_row,
377 target_idx: row,

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_fieldMethod · 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