Extract a record declaration (Java 16+).
(&self, node: &Node, source: &str, file_path: &str)
| 219 | |
| 220 | /// Extract a record declaration (Java 16+). |
| 221 | fn extract_record(&self, node: &Node, source: &str, file_path: &str) -> Option<Entity> { |
| 222 | let name_node = node.child_by_field_name("name")?; |
| 223 | let name = self.node_text(&name_node, source); |
| 224 | |
| 225 | let line = node.start_position().row as u32 + 1; |
| 226 | let end_line = node.end_position().row as u32 + 1; |
| 227 | |
| 228 | let exported = self.has_modifier(node, source, "public"); |
| 229 | |
| 230 | let params = node |
| 231 | .child_by_field_name("parameters") |
| 232 | .map(|n| self.node_text(&n, source)) |
| 233 | .unwrap_or_default(); |
| 234 | |
| 235 | let sig = format!( |
| 236 | "{}record {}{}", |
| 237 | if exported { "public " } else { "" }, |
| 238 | name, |
| 239 | params |
| 240 | ); |
| 241 | let mut entity = Entity::new(name, EntityKind::Class, file_path, line, end_line); |
| 242 | entity = entity.with_signature(sig); |
| 243 | if exported { |
| 244 | entity.exported = true; |
| 245 | } |
| 246 | |
| 247 | Some(entity) |
| 248 | } |
| 249 | |
| 250 | /// Extract an annotation type declaration (`@interface`). |
| 251 | fn extract_annotation_type( |
no test coverage detected