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

Method synthesize_record_components

codegraph-kernel/src/java.rs:1492–1542  ·  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

1490 /// synthesizeRecordComponents (languages/java.ts): per record component a
1491 /// private field and a public accessor, anchored on the component's name.
1492 fn synthesize_record_components(&mut self, record_node: Node<'t>, record_row: u32) {
1493 let Some(params) = record_node.child_by_field_name("parameters") else { return };
1494 let (mut taken_methods, mut taken_fields) = self.declared_member_names(record_row);
1495 for i in 0..params.named_child_count() {
1496 let Some(param) = params.named_child(i) else { continue };
1497 if param.kind() != "formal_parameter" {
1498 continue;
1499 }
1500 let (Some(name_node), Some(type_node)) =
1501 (param.child_by_field_name("name"), param.child_by_field_name("type"))
1502 else {
1503 continue;
1504 };
1505 let name = self.text(name_node).trim().to_string();
1506 let type_text = self.text(type_node).trim().to_string();
1507 if name.is_empty() {
1508 continue;
1509 }
1510 if !taken_fields.contains(&name) {
1511 taken_fields.insert(name.clone());
1512 self.create_node(
1513 "field",
1514 &name,
1515 name_node,
1516 Extra {
1517 visibility: Some(2),
1518 is_static: Some(false),
1519 signature: Some(format!("{type_text} {name}")),
1520 ..Extra::default()
1521 },
1522 );
1523 }
1524 if !taken_methods.contains(&name) {
1525 taken_methods.insert(name.clone());
1526 let return_type = self.normalize_java_type(Some(type_node));
1527 self.create_node(
1528 "method",
1529 &name,
1530 name_node,
1531 Extra {
1532 visibility: Some(1),
1533 is_static: Some(false),
1534 signature: Some(format!("{type_text} {name}()")),
1535 docstring: Some("Implicit record component accessor".to_string()),
1536 return_type,
1537 ..Extra::default()
1538 },
1539 );
1540 }
1541 }
1542 }
1543
1544 fn synthesize_lombok_members(&mut self, class_node: Node<'t>, class_row: u32) {
1545 let class_anns = self.lombok_annotation_names(class_node);

Callers 1

extract_classMethod · 0.80

Calls 4

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

Tested by

no test coverage detected