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

Method create_node

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

Source from the content-addressed store, hash-verified

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