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

Function NestedNameToEnum

private/bufpkg/bufprotosource/bufprotosource.go:675–691  ·  view source on GitHub ↗

NestedNameToEnum maps the Enums in the ContainerDescriptor to a map from nested name to Enum. Returns error if Enums do not have unique nested names within the ContainerDescriptor, which should generally never happen for properly-formed ContainerDescriptors.

(containerDescriptor ContainerDescriptor)

Source from the content-addressed store, hash-verified

673// Returns error if Enums do not have unique nested names within the ContainerDescriptor,
674// which should generally never happen for properly-formed ContainerDescriptors.
675func NestedNameToEnum(containerDescriptor ContainerDescriptor) (map[string]Enum, error) {
676 nestedNameToEnum := make(map[string]Enum)
677 if err := ForEachEnum(
678 func(enum Enum) error {
679 nestedName := enum.NestedName()
680 if _, ok := nestedNameToEnum[nestedName]; ok {
681 return fmt.Errorf("duplicate enum: %q", nestedName)
682 }
683 nestedNameToEnum[nestedName] = enum
684 return nil
685 },
686 containerDescriptor,
687 ); err != nil {
688 return nil, err
689 }
690 return nestedNameToEnum, nil
691}
692
693// NestedNameToExtension maps the Enums in the ContainerDescriptor to a map from
694// nested name to extension Field.

Callers 1

Calls 2

ForEachEnumFunction · 0.85
NestedNameMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…