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

Method create_node

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

Source from the content-addressed store, hash-verified

225 }
226
227 fn create_node(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra) -> Option<u32> {
228 if name.is_empty() {
229 return None;
230 }
231 let start_line = self.line_of(node);
232 let column = self.col_of(node);
233 let id = self.node_id_allocator.generate(self.file_path, kind, name, start_line, column);
234 let end_line = node.end_position().row as u32 + 1;
235
236 let qualified = extra.qualified_name.unwrap_or_else(|| {
237 let mut parts: Vec<&str> = Vec::new();
238 for s in &self.stack {
239 if s.kind != "file" {
240 parts.push(&s.name);
241 }
242 }
243 let mut qn = parts.join("::");
244 if !qn.is_empty() {
245 qn.push_str("::");
246 }
247 qn.push_str(name);
248 qn
249 });
250
251 let mut flags = BoolFlags::default();
252 if let Some(v) = extra.is_exported {
253 flags.set(FLAG_IS_EXPORTED, v);
254 }
255 let name_ref = self.arena.put(name);
256 let qn_ref = self.arena.put(&qualified);
257 let id_ref = self.arena.put(&id);
258 let doc_ref = opt_str(&mut self.arena, extra.docstring.as_deref());
259 let sig_ref = opt_str(&mut self.arena, extra.signature.as_deref());
260 let ret_ref = opt_str(&mut self.arena, extra.return_type.as_deref());
261 let row = self.tables.push_node(&NodeRow {
262 kind: node_kind_index(kind).unwrap(),
263 visibility: 0,
264 flags,
265 start_line,
266 end_line,
267 start_column: self.col_of(node),
268 end_column: self.end_col_of(node),
269 name: name_ref,
270 qualified_name: qn_ref,
271 id: id_ref,
272 docstring: doc_ref,
273 signature: sig_ref,
274 decorators: NONE_STR,
275 type_parameters: NONE_STR,
276 return_type: ret_ref,
277 extra_json: NONE_STR,
278 });
279 self.nodes_meta.push(NodeMeta { kind, name: name.to_string() });
280 self.node_ids.push(id);
281
282 let parent_row = self.top_row();
283 self.tables.push_edge(&EdgeRow {
284 source_idx: parent_row,

Callers 6

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