MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / visit_def

Method visit_def

src/extraction/elixir_extractor.rs:205–260  ·  view source on GitHub ↗
(state: &mut ExtractionState, node: TsNode<'_>, is_private: bool)

Source from the content-addressed store, hash-verified

203 }
204
205 fn visit_def(state: &mut ExtractionState, node: TsNode<'_>, is_private: bool) {
206 // def name(args) do ... end
207 let name = Self::call_arg_name(state, node).unwrap_or_else(|| "?".to_string());
208 let start_line = node.start_position().row as u32;
209 let sig = Self::first_line(state, node);
210 let qualified_name = format!("{}::{}", state.qualified_prefix(), name);
211 let id = generate_node_id(&state.file_path, &NodeKind::Function, &name, start_line);
212 let visibility = if is_private {
213 Visibility::Private
214 } else {
215 Visibility::Pub
216 };
217
218 // Extract @doc attribute from preceding attribute call.
219 let docstring = Self::extract_doc(state, node);
220
221 let graph_node = Node {
222 id: id.clone(),
223 kind: NodeKind::Function,
224 name,
225 qualified_name,
226 file_path: state.file_path.clone(),
227 start_line,
228 attrs_start_line: start_line,
229 end_line: node.end_position().row as u32,
230 start_column: node.start_position().column as u32,
231 end_column: node.end_position().column as u32,
232 signature: sig,
233 docstring,
234 visibility,
235 is_async: false,
236 branches: 0,
237 loops: 0,
238 returns: 0,
239 max_nesting: 0,
240 unsafe_blocks: 0,
241 unchecked_calls: 0,
242 assertions: 0,
243 updated_at: state.timestamp,
244 parent_id: None,
245 };
246 state.nodes.push(graph_node);
247
248 if let Some(parent_id) = state.parent_node_id() {
249 state.edges.push(Edge {
250 source: parent_id.to_string(),
251 target: id.clone(),
252 kind: EdgeKind::Contains,
253 line: Some(start_line),
254 });
255 }
256
257 if let Some(body) = Self::find_do_block(node) {
258 Self::extract_calls(state, body, &id);
259 }
260 }
261
262 fn visit_defmacro(state: &mut ExtractionState, node: TsNode<'_>) {

Callers

nothing calls this directly

Calls 4

first_lineFunction · 0.85
generate_node_idFunction · 0.85
pushMethod · 0.80
parent_node_idMethod · 0.45

Tested by

no test coverage detected