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

Method create_node

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

Source from the content-addressed store, hash-verified

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

Callers 7

extract_fn_or_methodMethod · 0.45
extract_interfaceMethod · 0.45
extract_aggregateMethod · 0.45
extract_enumMethod · 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