Extract a class method declaration.
(state: &mut ExtractionState, node: TsNode<'_>)
| 233 | |
| 234 | /// Extract a class method declaration. |
| 235 | fn visit_method(state: &mut ExtractionState, node: TsNode<'_>) { |
| 236 | let name = find_direct_child_by_kind(node, "name") |
| 237 | .map_or_else(|| "<anonymous>".to_string(), |n| state.node_text(n)); |
| 238 | |
| 239 | let visibility = Self::extract_visibility(state, node); |
| 240 | let signature = Some(Self::extract_function_signature(state, node)); |
| 241 | let docstring = Self::extract_docstring(state, node); |
| 242 | let start_line = node.start_position().row as u32; |
| 243 | let end_line = node.end_position().row as u32; |
| 244 | let start_column = node.start_position().column as u32; |
| 245 | let end_column = node.end_position().column as u32; |
| 246 | let qualified_name = format!("{}::{}", state.qualified_prefix(), name); |
| 247 | let id = generate_node_id(&state.file_path, &NodeKind::Method, &name, start_line); |
| 248 | let metrics = count_complexity(node, &PHP_COMPLEXITY, &state.source); |
| 249 | |
| 250 | let graph_node = Node { |
| 251 | id: id.clone(), |
| 252 | kind: NodeKind::Method, |
| 253 | name: name.clone(), |
| 254 | qualified_name, |
| 255 | file_path: state.file_path.clone(), |
| 256 | start_line, |
| 257 | attrs_start_line: start_line, |
| 258 | end_line, |
| 259 | start_column, |
| 260 | end_column, |
| 261 | signature, |
| 262 | docstring, |
| 263 | visibility, |
| 264 | is_async: false, |
| 265 | branches: metrics.branches, |
| 266 | loops: metrics.loops, |
| 267 | returns: metrics.returns, |
| 268 | max_nesting: metrics.max_nesting, |
| 269 | unsafe_blocks: metrics.unsafe_blocks, |
| 270 | unchecked_calls: metrics.unchecked_calls, |
| 271 | assertions: metrics.assertions, |
| 272 | updated_at: state.timestamp, |
| 273 | parent_id: None, |
| 274 | }; |
| 275 | state.nodes.push(graph_node); |
| 276 | |
| 277 | // Contains edge from parent class/trait/interface. |
| 278 | if let Some(parent_id) = state.parent_node_id() { |
| 279 | state.edges.push(Edge { |
| 280 | source: parent_id.to_string(), |
| 281 | target: id.clone(), |
| 282 | kind: EdgeKind::Contains, |
| 283 | line: Some(start_line), |
| 284 | }); |
| 285 | } |
| 286 | |
| 287 | Self::extract_annotations(state, node, &id); |
| 288 | |
| 289 | // Extract call sites from the method body. |
| 290 | if let Some(body) = find_direct_child_by_kind(node, "compound_statement") { |
| 291 | Self::extract_call_sites(state, body, &id); |
| 292 | } |
nothing calls this directly
no test coverage detected