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

Method create_node

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

Source from the content-addressed store, hash-verified

298 // --- createNode ------------------------------------------------------------
299
300 fn create_node(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra) -> Option<u32> {
301 if name.is_empty() {
302 return None;
303 }
304 let start_line = self.line_of(node);
305 let column = self.col_of(node);
306 let id = self.node_id_allocator.generate(self.file_path, kind, name, start_line, column);
307 let end_line = node.end_position().row as u32 + 1; // no resolveBody for java
308
309 let qualified = {
310 let mut parts: Vec<&str> = Vec::new();
311 for s in &self.stack {
312 if s.kind != "file" {
313 parts.push(&s.name);
314 }
315 }
316 let mut qn = parts.join("::");
317 if !qn.is_empty() {
318 qn.push_str("::");
319 }
320 qn.push_str(name);
321 qn
322 };
323
324 let mut flags = BoolFlags::default();
325 if let Some(v) = extra.is_static {
326 flags.set(FLAG_IS_STATIC, v);
327 }
328 let name_ref = self.arena.put(name);
329 let qn_ref = self.arena.put(&qualified);
330 let id_ref = self.arena.put(&id);
331 let doc_ref = opt_str(&mut self.arena, extra.docstring.as_deref());
332 let sig_ref = opt_str(&mut self.arena, extra.signature.as_deref());
333 let ret_ref = opt_str(&mut self.arena, extra.return_type.as_deref());
334 let dec_ref: StrRef = match &extra.decorators {
335 Some(list) if !list.is_empty() => self.arena.put_list(list),
336 _ => NONE_STR,
337 };
338 let row = self.tables.push_node(&NodeRow {
339 kind: node_kind_index(kind).unwrap(),
340 visibility: extra.visibility.unwrap_or(0),
341 flags,
342 start_line,
343 end_line,
344 start_column: self.col_of(node),
345 end_column: self.end_col_of(node),
346 name: name_ref,
347 qualified_name: qn_ref,
348 id: id_ref,
349 docstring: doc_ref,
350 signature: sig_ref,
351 decorators: dec_ref,
352 type_parameters: NONE_STR,
353 return_type: ret_ref,
354 extra_json: NONE_STR,
355 });
356 self.nodes_meta.push(NodeMeta { kind, name: name.to_string(), qualified_name: qualified });
357 self.node_ids.push(id);

Callers 12

extractFunction · 0.45
extract_classMethod · 0.45
extract_methodMethod · 0.45
extract_functionMethod · 0.45
extract_interfaceMethod · 0.45
extract_enumMethod · 0.45
extract_enum_membersMethod · 0.45
extract_fieldMethod · 0.45
extract_variableMethod · 0.45
extract_importMethod · 0.45

Calls 15

node_kind_indexFunction · 0.85
edge_kind_indexFunction · 0.85
pushMethod · 0.80
put_listMethod · 0.80
push_nodeMethod · 0.80
push_edgeMethod · 0.80
opt_strFunction · 0.70
putMethod · 0.65
unwrapMethod · 0.60
line_ofMethod · 0.45
col_ofMethod · 0.45
generateMethod · 0.45

Tested by

no test coverage detected