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

Method create_node

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

Callers 5

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

Calls 14

node_idFunction · 0.85
node_kind_indexFunction · 0.85
edge_kind_indexFunction · 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
col_ofMethod · 0.45

Tested by

no test coverage detected