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

Method create_node

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

Source from the content-addressed store, hash-verified

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

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

Tested by

no test coverage detected