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

Method create_node

codegraph-kernel/src/rlang.rs:178–243  ·  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 id = ids::node_id(self.file_path, kind, name, start_line);
184
185 // buildQualifiedName (tree-sitter.ts:1447-1460): non-file stack names
186 // joined `::` (namespacePrefix is always empty for R).
187 let qualified = {
188 let mut parts: Vec<&str> = Vec::new();
189 for s in &self.stack {
190 if s.kind != "file" {
191 parts.push(&s.name);
192 }
193 }
194 let mut qn = parts.join("::");
195 if !qn.is_empty() {
196 qn.push_str("::");
197 }
198 qn.push_str(name);
199 qn
200 };
201
202 let name_ref = self.arena.put(name);
203 let qn_ref = self.arena.put(&qualified);
204 let id_ref = self.arena.put(&id);
205 let sig_ref = match signature {
206 Some(s) => self.arena.put(s),
207 None => NONE_STR,
208 };
209 let row = self.tables.push_node(&NodeRow {
210 kind: node_kind_index(kind).unwrap(),
211 visibility: 0,
212 flags: BoolFlags::default(),
213 start_line,
214 end_line: node.end_position().row as u32 + 1,
215 start_column: self.col_of(node),
216 end_column: self.end_col_of(node),
217 name: name_ref,
218 qualified_name: qn_ref,
219 id: id_ref,
220 docstring: NONE_STR,
221 signature: sig_ref,
222 decorators: NONE_STR,
223 type_parameters: NONE_STR,
224 return_type: NONE_STR,
225 extra_json: NONE_STR,
226 });
227
228 // Containment edge from the stack top (always non-empty — file node).
229 let parent_row = self.top_row();
230 self.tables.push_edge(&EdgeRow {
231 source_idx: parent_row,
232 target_idx: row,
233 kind: edge_kind_index("contains").unwrap(),
234 provenance: 0,
235 line: NONE,

Callers 3

hook_callMethod · 0.45
hook_binary_operatorMethod · 0.45
emit_method_argMethod · 0.45

Calls 12

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
unwrapMethod · 0.60
line_ofMethod · 0.45
joinMethod · 0.45
col_ofMethod · 0.45
end_col_ofMethod · 0.45
top_rowMethod · 0.45

Tested by

no test coverage detected