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

Method create_node

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

Source from the content-addressed store, hash-verified

293 // --- createNode (tree-sitter.ts:1308) ---------------------------------
294
295 fn create_node(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra) -> Option<u32> {
296 if name.is_empty() {
297 return None;
298 }
299 let start_line = self.line_of(node);
300 let column = self.col_of(node);
301 let id = self.node_id_allocator.generate(self.file_path, kind, name, start_line, column);
302
303 // buildQualifiedName (:1447-1460) — non-file stack names, `::`-joined;
304 // namespacePrefix always empty (no C++ namespaces, no scala namespace).
305 let qualified = {
306 let mut parts: Vec<&str> = Vec::new();
307 for s in &self.stack {
308 if s.kind != "file" {
309 parts.push(&s.name);
310 }
311 }
312 let mut qn = parts.join("::");
313 if !qn.is_empty() {
314 qn.push_str("::");
315 }
316 qn.push_str(name);
317 qn
318 };
319
320 let name_ref = self.arena.put(name);
321 let qn_ref = self.arena.put(&qualified);
322 let id_ref = self.arena.put(&id);
323 let doc_ref = opt_str(&mut self.arena, extra.docstring.as_deref());
324 let sig_ref = opt_str(&mut self.arena, extra.signature.as_deref());
325 let ret_ref = opt_str(&mut self.arena, extra.return_type.as_deref());
326 let mut flags = BoolFlags::default();
327 if let Some(v) = extra.is_async {
328 flags.set(FLAG_IS_ASYNC, v);
329 }
330 if let Some(v) = extra.is_static {
331 flags.set(FLAG_IS_STATIC, v);
332 }
333 let row = self.tables.push_node(&NodeRow {
334 kind: node_kind_index(kind).unwrap(),
335 visibility: extra.visibility,
336 flags,
337 start_line,
338 end_line: node.end_position().row as u32 + 1, // no resolveBody hook
339 start_column: self.col_of(node),
340 end_column: self.end_col_of(node),
341 name: name_ref,
342 qualified_name: qn_ref,
343 id: id_ref,
344 docstring: doc_ref,
345 signature: sig_ref,
346 decorators: NONE_STR,
347 type_parameters: NONE_STR,
348 return_type: ret_ref,
349 extra_json: NONE_STR,
350 });
351 self.node_ids.push(id.clone());
352 if kind == "function" || kind == "method" {

Callers 6

hookMethod · 0.45
extract_classMethod · 0.45
extract_enumMethod · 0.45
extract_type_aliasMethod · 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