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

Method create_node

codegraph-kernel/src/rlang.rs:178–244  ·  view source on GitHub ↗
(&mut self, kind: &'static str, name: &str, node: Node<'t>, signature: Option<&str>)

Source from the content-addressed store, hash-verified

176 // body-extension is dead (no resolveBody hook).
177
178 fn create_node(&mut self, kind: &'static str, name: &str, node: Node<'t>, signature: Option<&str>) -> Option<u32> {
179 if name.is_empty() {
180 return None;
181 }
182 let start_line = self.line_of(node);
183 let column = self.col_of(node);
184 let id = self.node_id_allocator.generate(self.file_path, kind, name, start_line, column);
185
186 // buildQualifiedName (tree-sitter.ts:1447-1460): non-file stack names
187 // joined `::` (namespacePrefix is always empty for R).
188 let qualified = {
189 let mut parts: Vec<&str> = Vec::new();
190 for s in &self.stack {
191 if s.kind != "file" {
192 parts.push(&s.name);
193 }
194 }
195 let mut qn = parts.join("::");
196 if !qn.is_empty() {
197 qn.push_str("::");
198 }
199 qn.push_str(name);
200 qn
201 };
202
203 let name_ref = self.arena.put(name);
204 let qn_ref = self.arena.put(&qualified);
205 let id_ref = self.arena.put(&id);
206 let sig_ref = match signature {
207 Some(s) => self.arena.put(s),
208 None => NONE_STR,
209 };
210 let row = self.tables.push_node(&NodeRow {
211 kind: node_kind_index(kind).unwrap(),
212 visibility: 0,
213 flags: BoolFlags::default(),
214 start_line,
215 end_line: node.end_position().row as u32 + 1,
216 start_column: self.col_of(node),
217 end_column: self.end_col_of(node),
218 name: name_ref,
219 qualified_name: qn_ref,
220 id: id_ref,
221 docstring: NONE_STR,
222 signature: sig_ref,
223 decorators: NONE_STR,
224 type_parameters: NONE_STR,
225 return_type: NONE_STR,
226 extra_json: NONE_STR,
227 });
228
229 // Containment edge from the stack top (always non-empty — file node).
230 let parent_row = self.top_row();
231 self.tables.push_edge(&EdgeRow {
232 source_idx: parent_row,
233 target_idx: row,
234 kind: edge_kind_index("contains").unwrap(),
235 provenance: 0,

Callers 3

hook_callMethod · 0.45
hook_binary_operatorMethod · 0.45
emit_method_argMethod · 0.45

Calls 13

node_kind_indexFunction · 0.85
edge_kind_indexFunction · 0.85
pushMethod · 0.80
push_nodeMethod · 0.80
push_edgeMethod · 0.80
putMethod · 0.65
unwrapMethod · 0.60
line_ofMethod · 0.45
col_ofMethod · 0.45
generateMethod · 0.45
joinMethod · 0.45
end_col_ofMethod · 0.45

Tested by

no test coverage detected