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

Function PackageToNestedNameToEnum

private/bufpkg/bufprotosource/bufprotosource.go:746–770  ·  view source on GitHub ↗

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

(files ...File)

Source from the content-addressed store, hash-verified

744// Returns error if the Enums do not have unique nested names within the packages,
745// which should generally never happen for properly-formed Files.
746func PackageToNestedNameToEnum(files ...File) (map[string]map[string]Enum, error) {
747 packageToNestedNameToEnum := make(map[string]map[string]Enum)
748 for _, file := range files {
749 if err := ForEachEnum(
750 func(enum Enum) error {
751 pkg := enum.File().Package()
752 nestedName := enum.NestedName()
753 nestedNameToEnum, ok := packageToNestedNameToEnum[pkg]
754 if !ok {
755 nestedNameToEnum = make(map[string]Enum)
756 packageToNestedNameToEnum[pkg] = nestedNameToEnum
757 }
758 if _, ok := nestedNameToEnum[nestedName]; ok {
759 return fmt.Errorf("duplicate enum in package %q: %q", pkg, nestedName)
760 }
761 nestedNameToEnum[nestedName] = enum
762 return nil
763 },
764 file,
765 ); err != nil {
766 return nil, err
767 }
768 }
769 return packageToNestedNameToEnum, nil
770}
771
772// PackageToNestedNameToExtension maps the extension Fields in the Files to a map
773// from package to nested name to Field.

Callers 1

Calls 4

ForEachEnumFunction · 0.85
PackageMethod · 0.65
FileMethod · 0.65
NestedNameMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…