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)
| 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. |
| 746 | func 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. |
no test coverage detected
searching dependent graphs…