MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / extract_record

Method extract_record

atomic-semantic/src/parsers/java.rs:221–248  ·  view source on GitHub ↗

Extract a record declaration (Java 16+).

(&self, node: &Node, source: &str, file_path: &str)

Source from the content-addressed store, hash-verified

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(

Callers 1

walk_treeMethod · 0.80

Calls 3

has_modifierMethod · 0.80
with_signatureMethod · 0.80
node_textMethod · 0.45

Tested by

no test coverage detected