(
&mut self,
package: &str,
parents: &[String],
descriptor: DescriptorProto,
descriptor_path: &[i32],
comments: &SourceCodeComments,
)
| 503 | } |
| 504 | |
| 505 | fn register_message( |
| 506 | &mut self, |
| 507 | package: &str, |
| 508 | parents: &[String], |
| 509 | descriptor: DescriptorProto, |
| 510 | descriptor_path: &[i32], |
| 511 | comments: &SourceCodeComments, |
| 512 | ) { |
| 513 | let name = descriptor.name.clone().unwrap_or_default(); |
| 514 | let mut path = parents.to_owned(); |
| 515 | path.push(name.clone()); |
| 516 | let full_name = canonical_name(package, &path); |
| 517 | let is_map = descriptor |
| 518 | .options |
| 519 | .as_ref() |
| 520 | .and_then(|opt| opt.map_entry) |
| 521 | .unwrap_or(false); |
| 522 | let description = comments.comment_for(descriptor_path).map(|s| s.to_string()); |
| 523 | let mut field_comments = HashMap::new(); |
| 524 | for (idx, field) in descriptor.field.iter().enumerate() { |
| 525 | if let Some(field_name) = field.name.as_ref() { |
| 526 | let field_path = extend_path(descriptor_path, 2, idx as i32); |
| 527 | if let Some(comment) = comments.comment_for(&field_path) { |
| 528 | field_comments.insert(field_name.clone(), comment.to_string()); |
| 529 | } |
| 530 | } |
| 531 | } |
| 532 | let info = MessageInfo { |
| 533 | full_name: full_name.clone(), |
| 534 | descriptor: descriptor.clone(), |
| 535 | is_map_entry: is_map, |
| 536 | description, |
| 537 | field_comments, |
| 538 | }; |
| 539 | self.messages.insert(full_name.clone(), info); |
| 540 | |
| 541 | for (idx, nested) in descriptor.nested_type.into_iter().enumerate() { |
| 542 | let nested_path = extend_path(descriptor_path, 3, idx as i32); |
| 543 | self.register_message(package, &path, nested, &nested_path, comments); |
| 544 | } |
| 545 | for (idx, enumeration) in descriptor.enum_type.into_iter().enumerate() { |
| 546 | let enum_path = extend_path(descriptor_path, 4, idx as i32); |
| 547 | self.register_enum(package, &path, enumeration, &enum_path, comments); |
| 548 | } |
| 549 | } |
| 550 | |
| 551 | fn register_enum( |
| 552 | &mut self, |
no test coverage detected