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

Method create_node

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

Source from the content-addressed store, hash-verified

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