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

Method create_node

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

Source from the content-addressed store, hash-verified

273 }
274
275 fn create_node(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra) -> Option<u32> {
276 if name.is_empty() {
277 return None;
278 }
279 let start_line = self.line_of(node);
280 let column = self.col_of(node);
281 let id = self.node_id_allocator.generate(self.file_path, kind, name, start_line, column);
282 let end_line = node.end_position().row as u32 + 1;
283
284 let qualified = {
285 let mut parts: Vec<&str> = Vec::new();
286 for s in &self.stack {
287 if s.kind != "file" {
288 parts.push(&s.name);
289 }
290 }
291 let mut qn = parts.join("::");
292 if !qn.is_empty() {
293 qn.push_str("::");
294 }
295 qn.push_str(name);
296 qn
297 };
298
299 let mut flags = BoolFlags::default();
300 if let Some(v) = extra.is_async {
301 flags.set(FLAG_IS_ASYNC, v);
302 }
303 if let Some(v) = extra.is_static {
304 flags.set(FLAG_IS_STATIC, v);
305 }
306 let name_ref = self.arena.put(name);
307 let qn_ref = self.arena.put(&qualified);
308 let id_ref = self.arena.put(&id);
309 let doc_ref = opt_str(&mut self.arena, extra.docstring.as_deref());
310 let sig_ref = opt_str(&mut self.arena, extra.signature.as_deref());
311 let row = self.tables.push_node(&NodeRow {
312 kind: node_kind_index(kind).unwrap(),
313 visibility: 0,
314 flags,
315 start_line,
316 end_line,
317 start_column: self.col_of(node),
318 end_column: self.end_col_of(node),
319 name: name_ref,
320 qualified_name: qn_ref,
321 id: id_ref,
322 docstring: doc_ref,
323 signature: sig_ref,
324 decorators: NONE_STR,
325 type_parameters: NONE_STR,
326 return_type: NONE_STR,
327 extra_json: NONE_STR,
328 });
329 self.node_ids.push(id);
330
331 let parent_row = self.top_row();
332 self.tables.push_edge(&EdgeRow {

Callers 5

extract_functionMethod · 0.45
extract_methodMethod · 0.45
extract_classMethod · 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