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

Method create_node

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

Source from the content-addressed store, hash-verified

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