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

Method create_node

codegraph-kernel/src/scala.rs:295–388  ·  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 id = ids::node_id(self.file_path, kind, name, start_line);
301
302 // buildQualifiedName (:1447-1460) — non-file stack names, `::`-joined;
303 // namespacePrefix always empty (no C++ namespaces, no scala namespace).
304 let qualified = {
305 let mut parts: Vec<&str> = Vec::new();
306 for s in &self.stack {
307 if s.kind != "file" {
308 parts.push(&s.name);
309 }
310 }
311 let mut qn = parts.join("::");
312 if !qn.is_empty() {
313 qn.push_str("::");
314 }
315 qn.push_str(name);
316 qn
317 };
318
319 let name_ref = self.arena.put(name);
320 let qn_ref = self.arena.put(&qualified);
321 let id_ref = self.arena.put(&id);
322 let doc_ref = opt_str(&mut self.arena, extra.docstring.as_deref());
323 let sig_ref = opt_str(&mut self.arena, extra.signature.as_deref());
324 let ret_ref = opt_str(&mut self.arena, extra.return_type.as_deref());
325 let mut flags = BoolFlags::default();
326 if let Some(v) = extra.is_async {
327 flags.set(FLAG_IS_ASYNC, v);
328 }
329 if let Some(v) = extra.is_static {
330 flags.set(FLAG_IS_STATIC, v);
331 }
332 let row = self.tables.push_node(&NodeRow {
333 kind: node_kind_index(kind).unwrap(),
334 visibility: extra.visibility,
335 flags,
336 start_line,
337 end_line: node.end_position().row as u32 + 1, // no resolveBody hook
338 start_column: self.col_of(node),
339 end_column: self.end_col_of(node),
340 name: name_ref,
341 qualified_name: qn_ref,
342 id: id_ref,
343 docstring: doc_ref,
344 signature: sig_ref,
345 decorators: NONE_STR,
346 type_parameters: NONE_STR,
347 return_type: ret_ref,
348 extra_json: NONE_STR,
349 });
350 self.node_ids.push(id.clone());
351 if kind == "function" || kind == "method" {
352 self.defined_fn_names.insert(name.to_string());

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_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