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

Method create_node

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

Source from the content-addressed store, hash-verified

199 // --- createNode (tree-sitter.ts:1308) ---------------------------------
200
201 fn create_node(&mut self, kind: &'static str, name: &str, node: Node<'t>, extra: Extra) -> Option<u32> {
202 if name.is_empty() {
203 return None;
204 }
205 let start_line = self.line_of(node);
206 let column = self.col_of(node);
207 let id = self.node_id_allocator.generate(self.file_path, kind, name, start_line, column);
208
209 // buildQualifiedName (1447-1460) — non-file stack NAMES joined `::`;
210 // the receiver override (extractMethod:1790-1792) replaces it whole.
211 let qualified = match &extra.qualified_name_override {
212 Some(qn) => qn.clone(),
213 None => {
214 let mut parts: Vec<&str> = Vec::new();
215 for s in &self.stack {
216 if s.kind != "file" {
217 parts.push(&s.name);
218 }
219 }
220 let mut qn = parts.join("::");
221 if !qn.is_empty() {
222 qn.push_str("::");
223 }
224 qn.push_str(name);
225 qn
226 }
227 };
228
229 let name_ref = self.arena.put(name);
230 let qn_ref = self.arena.put(&qualified);
231 let id_ref = self.arena.put(&id);
232 let doc_ref = opt_str(&mut self.arena, extra.docstring.as_deref());
233 let sig_ref = opt_str(&mut self.arena, extra.signature.as_deref());
234 let mut flags = BoolFlags::default();
235 if let Some(v) = extra.is_exported {
236 flags.set(FLAG_IS_EXPORTED, v);
237 }
238 let row = self.tables.push_node(&NodeRow {
239 kind: node_kind_index(kind).unwrap(),
240 visibility: 0,
241 flags,
242 start_line,
243 end_line: node.end_position().row as u32 + 1, // no resolveBody
244 start_column: self.col_of(node),
245 end_column: self.end_col_of(node),
246 name: name_ref,
247 qualified_name: qn_ref,
248 id: id_ref,
249 docstring: doc_ref,
250 signature: sig_ref,
251 decorators: NONE_STR,
252 type_parameters: NONE_STR,
253 return_type: NONE_STR,
254 extra_json: NONE_STR,
255 });
256 self.node_ids.push(id);
257 if kind == "function" || kind == "method" {
258 self.defined_fn_names.insert(name.to_string());

Callers 6

emit_requireMethod · 0.45
extract_functionMethod · 0.45
extract_methodMethod · 0.45
extract_variableMethod · 0.45
extract_type_aliasMethod · 0.45

Calls 15

node_kind_indexFunction · 0.85
edge_kind_indexFunction · 0.85
pushMethod · 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
joinMethod · 0.45

Tested by

no test coverage detected