Extract a method declaration.
(
&self,
node: &Node,
source: &str,
file_path: &str,
in_class: Option<&str>,
)
| 283 | |
| 284 | /// Extract a method declaration. |
| 285 | fn extract_method( |
| 286 | &self, |
| 287 | node: &Node, |
| 288 | source: &str, |
| 289 | file_path: &str, |
| 290 | in_class: Option<&str>, |
| 291 | ) -> Option<Entity> { |
| 292 | let name_node = node.child_by_field_name("name")?; |
| 293 | let name = self.node_text(&name_node, source); |
| 294 | |
| 295 | let line = node.start_position().row as u32 + 1; |
| 296 | let end_line = node.end_position().row as u32 + 1; |
| 297 | |
| 298 | let kind = if in_class.is_some() { |
| 299 | EntityKind::Method |
| 300 | } else { |
| 301 | EntityKind::Function |
| 302 | }; |
| 303 | |
| 304 | let exported = self.has_modifier(node, source, "public"); |
| 305 | |
| 306 | let signature = self.build_method_signature(node, source); |
| 307 | |
| 308 | let mut entity = Entity::new(name, kind, file_path, line, end_line); |
| 309 | if let Some(sig) = signature { |
| 310 | entity = entity.with_signature(sig); |
| 311 | } |
| 312 | if exported { |
| 313 | entity.exported = true; |
| 314 | } |
| 315 | |
| 316 | Some(entity) |
| 317 | } |
| 318 | |
| 319 | /// Extract a constructor declaration. |
| 320 | fn extract_constructor( |
no test coverage detected