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

Method create_node

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

Source from the content-addressed store, hash-verified

261 // --- createNode (tree-sitter.ts:1308) ---------------------------------
262
263 fn create_node(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra) -> Option<u32> {
264 if name.is_empty() {
265 return None;
266 }
267 let start_line = self.line_of(node);
268 let id = ids::node_id(self.file_path, kind, name, start_line);
269
270 let qualified = {
271 let mut parts: Vec<&str> = Vec::new();
272 for s in &self.stack {
273 if s.kind != "file" {
274 parts.push(&s.name);
275 }
276 }
277 let mut qn = parts.join("::");
278 if !qn.is_empty() {
279 qn.push_str("::");
280 }
281 qn.push_str(name);
282 qn
283 };
284
285 // endLine extension (:1322-1334) — LIVE for dart: a function/method
286 // node's endLine extends to its sibling function_body's end.
287 let mut end_line = node.end_position().row as u32 + 1;
288 if let Some(ext) = extra.end_line_override {
289 if ext > end_line {
290 end_line = ext;
291 }
292 }
293
294 let name_ref = self.arena.put(name);
295 let qn_ref = self.arena.put(&qualified);
296 let id_ref = self.arena.put(&id);
297 let doc_ref = opt_str(&mut self.arena, extra.docstring.as_deref());
298 let sig_ref = opt_str(&mut self.arena, extra.signature.as_deref());
299 let ret_ref = opt_str(&mut self.arena, extra.return_type.as_deref());
300 let mut flags = BoolFlags::default();
301 if let Some(v) = extra.is_async {
302 flags.set(FLAG_IS_ASYNC, v);
303 }
304 if let Some(v) = extra.is_static {
305 flags.set(FLAG_IS_STATIC, v);
306 }
307 let row = self.tables.push_node(&NodeRow {
308 kind: node_kind_index(kind).unwrap(),
309 visibility: extra.visibility,
310 flags,
311 start_line,
312 end_line,
313 start_column: self.col_of(node),
314 end_column: self.end_col_of(node),
315 name: name_ref,
316 qualified_name: qn_ref,
317 id: id_ref,
318 docstring: doc_ref,
319 signature: sig_ref,
320 decorators: NONE_STR,

Callers 8

visitMethod · 0.45
extract_functionMethod · 0.45
extract_methodMethod · 0.45
extract_classMethod · 0.45
extract_enumMethod · 0.45
extract_enum_membersMethod · 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