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

Method synthesize_record_components

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

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