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

Method create_node

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

Source from the content-addressed store, hash-verified

248 }
249
250 fn create_node(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra) -> Option<u32> {
251 if name.is_empty() {
252 return None;
253 }
254 let start_line = self.line_of(node);
255 let id = ids::node_id(self.file_path, kind, name, start_line);
256 let end_line = node.end_position().row as u32 + 1;
257
258 let qualified = extra.qualified_name.unwrap_or_else(|| {
259 let mut parts: Vec<&str> = Vec::new();
260 for s in &self.stack {
261 if s.kind != "file" {
262 parts.push(&s.name);
263 }
264 }
265 let mut qn = parts.join("::");
266 if !qn.is_empty() {
267 qn.push_str("::");
268 }
269 qn.push_str(name);
270 qn
271 });
272
273 let mut flags = BoolFlags::default();
274 if let Some(v) = extra.is_exported {
275 flags.set(FLAG_IS_EXPORTED, v);
276 }
277 if let Some(v) = extra.is_async {
278 flags.set(FLAG_IS_ASYNC, v);
279 }
280 let name_ref = self.arena.put(name);
281 let qn_ref = self.arena.put(&qualified);
282 let id_ref = self.arena.put(&id);
283 let doc_ref = opt_str(&mut self.arena, extra.docstring.as_deref());
284 let sig_ref = opt_str(&mut self.arena, extra.signature.as_deref());
285 let ret_ref = opt_str(&mut self.arena, extra.return_type.as_deref());
286 let row = self.tables.push_node(&NodeRow {
287 kind: node_kind_index(kind).unwrap(),
288 visibility: extra.visibility.unwrap_or(0),
289 flags,
290 start_line,
291 end_line,
292 start_column: self.col_of(node),
293 end_column: self.end_col_of(node),
294 name: name_ref,
295 qualified_name: qn_ref,
296 id: id_ref,
297 docstring: doc_ref,
298 signature: sig_ref,
299 decorators: NONE_STR,
300 type_parameters: NONE_STR,
301 return_type: ret_ref,
302 extra_json: NONE_STR,
303 });
304 self.nodes_meta.push(NodeMeta { kind, name: name.to_string() });
305 self.node_ids.push(id);
306
307 let parent_row = self.top_row();

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

Tested by

no test coverage detected