MCPcopy Create free account
hub / github.com/bufbuild/buf / NestedNameToMessage

Function NestedNameToMessage

private/bufpkg/bufprotosource/bufprotosource.go:848–864  ·  view source on GitHub ↗

NestedNameToMessage maps the Messages in the ContainerDescriptor to a map from nested name to Message. Returns error if Messages do not have unique nested names within the ContainerDescriptor, which should generally never happen for properly-formed files.

(containerDescriptor ContainerDescriptor)

Source from the content-addressed store, hash-verified

846// Returns error if Messages do not have unique nested names within the ContainerDescriptor,
847// which should generally never happen for properly-formed files.
848func NestedNameToMessage(containerDescriptor ContainerDescriptor) (map[string]Message, error) {
849 nestedNameToMessage := make(map[string]Message)
850 if err := ForEachMessage(
851 func(message Message) error {
852 nestedName := message.NestedName()
853 if _, ok := nestedNameToMessage[nestedName]; ok {
854 return fmt.Errorf("duplicate message: %q", nestedName)
855 }
856 nestedNameToMessage[nestedName] = message
857 return nil
858 },
859 containerDescriptor,
860 ); err != nil {
861 return nil, err
862 }
863 return nestedNameToMessage, nil
864}
865
866// FullNameToMessage maps the Messages in the Files to a map from full name to message.
867//

Calls 2

ForEachMessageFunction · 0.85
NestedNameMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…