FullNameToMessage maps the Messages in the Files to a map from full name to message. Returns error if the Messages do not have unique full names within the Files, which should generally never happen for properly-formed Files.
(files ...File)
| 868 | // Returns error if the Messages do not have unique full names within the Files, |
| 869 | // which should generally never happen for properly-formed Files. |
| 870 | func FullNameToMessage(files ...File) (map[string]Message, error) { |
| 871 | fullNameToMessage := make(map[string]Message) |
| 872 | for _, file := range files { |
| 873 | if err := ForEachMessage( |
| 874 | func(message Message) error { |
| 875 | fullName := message.FullName() |
| 876 | if _, ok := fullNameToMessage[fullName]; ok { |
| 877 | return fmt.Errorf("duplicate message: %q", fullName) |
| 878 | } |
| 879 | fullNameToMessage[fullName] = message |
| 880 | return nil |
| 881 | }, |
| 882 | file, |
| 883 | ); err != nil { |
| 884 | return nil, err |
| 885 | } |
| 886 | } |
| 887 | return fullNameToMessage, nil |
| 888 | } |
| 889 | |
| 890 | // PackageToNestedNameToMessage maps the Messages in the Files to a map from |
| 891 | // package to nested name to Message. |
no test coverage detected
searching dependent graphs…