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

Method create_node

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

Source from the content-addressed store, hash-verified

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

Callers 7

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