MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / synthesize_record_components

Method synthesize_record_components

codegraph-kernel/src/java.rs:1439–1488  ·  view source on GitHub ↗

synthesizeRecordComponents (languages/java.ts): per record component a private field and a public accessor, anchored on the component's name.

(&mut self, record_node: Node<'t>, record_row: u32)

Source from the content-addressed store, hash-verified

1437 /// synthesizeRecordComponents (languages/java.ts): per record component a
1438 /// private field and a public accessor, anchored on the component's name.
1439 fn synthesize_record_components(&mut self, record_node: Node<'t>, record_row: u32) {
1440 let Some(params) = record_node.child_by_field_name("parameters") else { return };
1441 let (mut taken_methods, mut taken_fields) = self.declared_member_names(record_row);
1442 for param in params.named_children(&mut params.walk()) {
1443 if param.kind() != "formal_parameter" {
1444 continue;
1445 }
1446 let (Some(name_node), Some(type_node)) =
1447 (param.child_by_field_name("name"), param.child_by_field_name("type"))
1448 else {
1449 continue;
1450 };
1451 let name = self.text(name_node).trim().to_string();
1452 let type_text = self.text(type_node).trim().to_string();
1453 if name.is_empty() {
1454 continue;
1455 }
1456 if !taken_fields.contains(&name) {
1457 taken_fields.insert(name.clone());
1458 self.create_node(
1459 "field",
1460 &name,
1461 name_node,
1462 Extra {
1463 visibility: Some(2),
1464 is_static: Some(false),
1465 signature: Some(format!("{type_text} {name}")),
1466 ..Extra::default()
1467 },
1468 );
1469 }
1470 if !taken_methods.contains(&name) {
1471 taken_methods.insert(name.clone());
1472 let return_type = self.normalize_java_type(Some(type_node));
1473 self.create_node(
1474 "method",
1475 &name,
1476 name_node,
1477 Extra {
1478 visibility: Some(1),
1479 is_static: Some(false),
1480 signature: Some(format!("{type_text} {name}()")),
1481 docstring: Some("Implicit record component accessor".to_string()),
1482 return_type,
1483 ..Extra::default()
1484 },
1485 );
1486 }
1487 }
1488 }
1489
1490 fn synthesize_lombok_members(&mut self, class_node: Node<'t>, class_row: u32) {
1491 let class_anns = self.lombok_annotation_names(class_node);

Callers 1

extract_classMethod · 0.80

Calls 5

declared_member_namesMethod · 0.80
normalize_java_typeMethod · 0.80
textMethod · 0.65
walkMethod · 0.45
create_nodeMethod · 0.45

Tested by

no test coverage detected