vendor/google.golang.org/protobuf/internal/filedesc/desc_list.go
changeset 260 445e01aede7e
parent 256 6d9efbef00a9
equal deleted inserted replaced
259:db4911b0c721 260:445e01aede7e
    15 	"google.golang.org/protobuf/encoding/protowire"
    15 	"google.golang.org/protobuf/encoding/protowire"
    16 	"google.golang.org/protobuf/internal/descfmt"
    16 	"google.golang.org/protobuf/internal/descfmt"
    17 	"google.golang.org/protobuf/internal/errors"
    17 	"google.golang.org/protobuf/internal/errors"
    18 	"google.golang.org/protobuf/internal/pragma"
    18 	"google.golang.org/protobuf/internal/pragma"
    19 	"google.golang.org/protobuf/reflect/protoreflect"
    19 	"google.golang.org/protobuf/reflect/protoreflect"
    20 	pref "google.golang.org/protobuf/reflect/protoreflect"
       
    21 )
    20 )
    22 
    21 
    23 type FileImports []pref.FileImport
    22 type FileImports []protoreflect.FileImport
    24 
    23 
    25 func (p *FileImports) Len() int                            { return len(*p) }
    24 func (p *FileImports) Len() int                            { return len(*p) }
    26 func (p *FileImports) Get(i int) pref.FileImport           { return (*p)[i] }
    25 func (p *FileImports) Get(i int) protoreflect.FileImport   { return (*p)[i] }
    27 func (p *FileImports) Format(s fmt.State, r rune)          { descfmt.FormatList(s, r, p) }
    26 func (p *FileImports) Format(s fmt.State, r rune)          { descfmt.FormatList(s, r, p) }
    28 func (p *FileImports) ProtoInternal(pragma.DoNotImplement) {}
    27 func (p *FileImports) ProtoInternal(pragma.DoNotImplement) {}
    29 
    28 
    30 type Names struct {
    29 type Names struct {
    31 	List []pref.Name
    30 	List []protoreflect.Name
    32 	once sync.Once
    31 	once sync.Once
    33 	has  map[pref.Name]int // protected by once
    32 	has  map[protoreflect.Name]int // protected by once
    34 }
    33 }
    35 
    34 
    36 func (p *Names) Len() int                            { return len(p.List) }
    35 func (p *Names) Len() int                            { return len(p.List) }
    37 func (p *Names) Get(i int) pref.Name                 { return p.List[i] }
    36 func (p *Names) Get(i int) protoreflect.Name         { return p.List[i] }
    38 func (p *Names) Has(s pref.Name) bool                { return p.lazyInit().has[s] > 0 }
    37 func (p *Names) Has(s protoreflect.Name) bool        { return p.lazyInit().has[s] > 0 }
    39 func (p *Names) Format(s fmt.State, r rune)          { descfmt.FormatList(s, r, p) }
    38 func (p *Names) Format(s fmt.State, r rune)          { descfmt.FormatList(s, r, p) }
    40 func (p *Names) ProtoInternal(pragma.DoNotImplement) {}
    39 func (p *Names) ProtoInternal(pragma.DoNotImplement) {}
    41 func (p *Names) lazyInit() *Names {
    40 func (p *Names) lazyInit() *Names {
    42 	p.once.Do(func() {
    41 	p.once.Do(func() {
    43 		if len(p.List) > 0 {
    42 		if len(p.List) > 0 {
    44 			p.has = make(map[pref.Name]int, len(p.List))
    43 			p.has = make(map[protoreflect.Name]int, len(p.List))
    45 			for _, s := range p.List {
    44 			for _, s := range p.List {
    46 				p.has[s] = p.has[s] + 1
    45 				p.has[s] = p.has[s] + 1
    47 			}
    46 			}
    48 		}
    47 		}
    49 	})
    48 	})
    65 	}
    64 	}
    66 	return nil
    65 	return nil
    67 }
    66 }
    68 
    67 
    69 type EnumRanges struct {
    68 type EnumRanges struct {
    70 	List   [][2]pref.EnumNumber // start inclusive; end inclusive
    69 	List   [][2]protoreflect.EnumNumber // start inclusive; end inclusive
    71 	once   sync.Once
    70 	once   sync.Once
    72 	sorted [][2]pref.EnumNumber // protected by once
    71 	sorted [][2]protoreflect.EnumNumber // protected by once
    73 }
    72 }
    74 
    73 
    75 func (p *EnumRanges) Len() int                     { return len(p.List) }
    74 func (p *EnumRanges) Len() int                             { return len(p.List) }
    76 func (p *EnumRanges) Get(i int) [2]pref.EnumNumber { return p.List[i] }
    75 func (p *EnumRanges) Get(i int) [2]protoreflect.EnumNumber { return p.List[i] }
    77 func (p *EnumRanges) Has(n pref.EnumNumber) bool {
    76 func (p *EnumRanges) Has(n protoreflect.EnumNumber) bool {
    78 	for ls := p.lazyInit().sorted; len(ls) > 0; {
    77 	for ls := p.lazyInit().sorted; len(ls) > 0; {
    79 		i := len(ls) / 2
    78 		i := len(ls) / 2
    80 		switch r := enumRange(ls[i]); {
    79 		switch r := enumRange(ls[i]); {
    81 		case n < r.Start():
    80 		case n < r.Start():
    82 			ls = ls[:i] // search lower
    81 			ls = ls[:i] // search lower
   127 	}
   126 	}
   128 	return fmt.Sprintf("%d to %d", r.Start(), r.End())
   127 	return fmt.Sprintf("%d to %d", r.Start(), r.End())
   129 }
   128 }
   130 
   129 
   131 type FieldRanges struct {
   130 type FieldRanges struct {
   132 	List   [][2]pref.FieldNumber // start inclusive; end exclusive
   131 	List   [][2]protoreflect.FieldNumber // start inclusive; end exclusive
   133 	once   sync.Once
   132 	once   sync.Once
   134 	sorted [][2]pref.FieldNumber // protected by once
   133 	sorted [][2]protoreflect.FieldNumber // protected by once
   135 }
   134 }
   136 
   135 
   137 func (p *FieldRanges) Len() int                      { return len(p.List) }
   136 func (p *FieldRanges) Len() int                              { return len(p.List) }
   138 func (p *FieldRanges) Get(i int) [2]pref.FieldNumber { return p.List[i] }
   137 func (p *FieldRanges) Get(i int) [2]protoreflect.FieldNumber { return p.List[i] }
   139 func (p *FieldRanges) Has(n pref.FieldNumber) bool {
   138 func (p *FieldRanges) Has(n protoreflect.FieldNumber) bool {
   140 	for ls := p.lazyInit().sorted; len(ls) > 0; {
   139 	for ls := p.lazyInit().sorted; len(ls) > 0; {
   141 		i := len(ls) / 2
   140 		i := len(ls) / 2
   142 		switch r := fieldRange(ls[i]); {
   141 		switch r := fieldRange(ls[i]); {
   143 		case n < r.Start():
   142 		case n < r.Start():
   144 			ls = ls[:i] // search lower
   143 			ls = ls[:i] // search lower
   219 	}
   218 	}
   220 	return fmt.Sprintf("%d to %d", r.Start(), r.End())
   219 	return fmt.Sprintf("%d to %d", r.Start(), r.End())
   221 }
   220 }
   222 
   221 
   223 type FieldNumbers struct {
   222 type FieldNumbers struct {
   224 	List []pref.FieldNumber
   223 	List []protoreflect.FieldNumber
   225 	once sync.Once
   224 	once sync.Once
   226 	has  map[pref.FieldNumber]struct{} // protected by once
   225 	has  map[protoreflect.FieldNumber]struct{} // protected by once
   227 }
   226 }
   228 
   227 
   229 func (p *FieldNumbers) Len() int                   { return len(p.List) }
   228 func (p *FieldNumbers) Len() int                           { return len(p.List) }
   230 func (p *FieldNumbers) Get(i int) pref.FieldNumber { return p.List[i] }
   229 func (p *FieldNumbers) Get(i int) protoreflect.FieldNumber { return p.List[i] }
   231 func (p *FieldNumbers) Has(n pref.FieldNumber) bool {
   230 func (p *FieldNumbers) Has(n protoreflect.FieldNumber) bool {
   232 	p.once.Do(func() {
   231 	p.once.Do(func() {
   233 		if len(p.List) > 0 {
   232 		if len(p.List) > 0 {
   234 			p.has = make(map[pref.FieldNumber]struct{}, len(p.List))
   233 			p.has = make(map[protoreflect.FieldNumber]struct{}, len(p.List))
   235 			for _, n := range p.List {
   234 			for _, n := range p.List {
   236 				p.has[n] = struct{}{}
   235 				p.has[n] = struct{}{}
   237 			}
   236 			}
   238 		}
   237 		}
   239 	})
   238 	})
   242 }
   241 }
   243 func (p *FieldNumbers) Format(s fmt.State, r rune)          { descfmt.FormatList(s, r, p) }
   242 func (p *FieldNumbers) Format(s fmt.State, r rune)          { descfmt.FormatList(s, r, p) }
   244 func (p *FieldNumbers) ProtoInternal(pragma.DoNotImplement) {}
   243 func (p *FieldNumbers) ProtoInternal(pragma.DoNotImplement) {}
   245 
   244 
   246 type OneofFields struct {
   245 type OneofFields struct {
   247 	List   []pref.FieldDescriptor
   246 	List   []protoreflect.FieldDescriptor
   248 	once   sync.Once
   247 	once   sync.Once
   249 	byName map[pref.Name]pref.FieldDescriptor        // protected by once
   248 	byName map[protoreflect.Name]protoreflect.FieldDescriptor        // protected by once
   250 	byJSON map[string]pref.FieldDescriptor           // protected by once
   249 	byJSON map[string]protoreflect.FieldDescriptor                   // protected by once
   251 	byText map[string]pref.FieldDescriptor           // protected by once
   250 	byText map[string]protoreflect.FieldDescriptor                   // protected by once
   252 	byNum  map[pref.FieldNumber]pref.FieldDescriptor // protected by once
   251 	byNum  map[protoreflect.FieldNumber]protoreflect.FieldDescriptor // protected by once
   253 }
   252 }
   254 
   253 
   255 func (p *OneofFields) Len() int                                         { return len(p.List) }
   254 func (p *OneofFields) Len() int                               { return len(p.List) }
   256 func (p *OneofFields) Get(i int) pref.FieldDescriptor                   { return p.List[i] }
   255 func (p *OneofFields) Get(i int) protoreflect.FieldDescriptor { return p.List[i] }
   257 func (p *OneofFields) ByName(s pref.Name) pref.FieldDescriptor          { return p.lazyInit().byName[s] }
   256 func (p *OneofFields) ByName(s protoreflect.Name) protoreflect.FieldDescriptor {
   258 func (p *OneofFields) ByJSONName(s string) pref.FieldDescriptor         { return p.lazyInit().byJSON[s] }
   257 	return p.lazyInit().byName[s]
   259 func (p *OneofFields) ByTextName(s string) pref.FieldDescriptor         { return p.lazyInit().byText[s] }
   258 }
   260 func (p *OneofFields) ByNumber(n pref.FieldNumber) pref.FieldDescriptor { return p.lazyInit().byNum[n] }
   259 func (p *OneofFields) ByJSONName(s string) protoreflect.FieldDescriptor {
   261 func (p *OneofFields) Format(s fmt.State, r rune)                       { descfmt.FormatList(s, r, p) }
   260 	return p.lazyInit().byJSON[s]
   262 func (p *OneofFields) ProtoInternal(pragma.DoNotImplement)              {}
   261 }
       
   262 func (p *OneofFields) ByTextName(s string) protoreflect.FieldDescriptor {
       
   263 	return p.lazyInit().byText[s]
       
   264 }
       
   265 func (p *OneofFields) ByNumber(n protoreflect.FieldNumber) protoreflect.FieldDescriptor {
       
   266 	return p.lazyInit().byNum[n]
       
   267 }
       
   268 func (p *OneofFields) Format(s fmt.State, r rune)          { descfmt.FormatList(s, r, p) }
       
   269 func (p *OneofFields) ProtoInternal(pragma.DoNotImplement) {}
   263 
   270 
   264 func (p *OneofFields) lazyInit() *OneofFields {
   271 func (p *OneofFields) lazyInit() *OneofFields {
   265 	p.once.Do(func() {
   272 	p.once.Do(func() {
   266 		if len(p.List) > 0 {
   273 		if len(p.List) > 0 {
   267 			p.byName = make(map[pref.Name]pref.FieldDescriptor, len(p.List))
   274 			p.byName = make(map[protoreflect.Name]protoreflect.FieldDescriptor, len(p.List))
   268 			p.byJSON = make(map[string]pref.FieldDescriptor, len(p.List))
   275 			p.byJSON = make(map[string]protoreflect.FieldDescriptor, len(p.List))
   269 			p.byText = make(map[string]pref.FieldDescriptor, len(p.List))
   276 			p.byText = make(map[string]protoreflect.FieldDescriptor, len(p.List))
   270 			p.byNum = make(map[pref.FieldNumber]pref.FieldDescriptor, len(p.List))
   277 			p.byNum = make(map[protoreflect.FieldNumber]protoreflect.FieldDescriptor, len(p.List))
   271 			for _, f := range p.List {
   278 			for _, f := range p.List {
   272 				// Field names and numbers are guaranteed to be unique.
   279 				// Field names and numbers are guaranteed to be unique.
   273 				p.byName[f.Name()] = f
   280 				p.byName[f.Name()] = f
   274 				p.byJSON[f.JSONName()] = f
   281 				p.byJSON[f.JSONName()] = f
   275 				p.byText[f.TextName()] = f
   282 				p.byText[f.TextName()] = f
   282 
   289 
   283 type SourceLocations struct {
   290 type SourceLocations struct {
   284 	// List is a list of SourceLocations.
   291 	// List is a list of SourceLocations.
   285 	// The SourceLocation.Next field does not need to be populated
   292 	// The SourceLocation.Next field does not need to be populated
   286 	// as it will be lazily populated upon first need.
   293 	// as it will be lazily populated upon first need.
   287 	List []pref.SourceLocation
   294 	List []protoreflect.SourceLocation
   288 
   295 
   289 	// File is the parent file descriptor that these locations are relative to.
   296 	// File is the parent file descriptor that these locations are relative to.
   290 	// If non-nil, ByDescriptor verifies that the provided descriptor
   297 	// If non-nil, ByDescriptor verifies that the provided descriptor
   291 	// is a child of this file descriptor.
   298 	// is a child of this file descriptor.
   292 	File pref.FileDescriptor
   299 	File protoreflect.FileDescriptor
   293 
   300 
   294 	once   sync.Once
   301 	once   sync.Once
   295 	byPath map[pathKey]int
   302 	byPath map[pathKey]int
   296 }
   303 }
   297 
   304 
   298 func (p *SourceLocations) Len() int                      { return len(p.List) }
   305 func (p *SourceLocations) Len() int                              { return len(p.List) }
   299 func (p *SourceLocations) Get(i int) pref.SourceLocation { return p.lazyInit().List[i] }
   306 func (p *SourceLocations) Get(i int) protoreflect.SourceLocation { return p.lazyInit().List[i] }
   300 func (p *SourceLocations) byKey(k pathKey) pref.SourceLocation {
   307 func (p *SourceLocations) byKey(k pathKey) protoreflect.SourceLocation {
   301 	if i, ok := p.lazyInit().byPath[k]; ok {
   308 	if i, ok := p.lazyInit().byPath[k]; ok {
   302 		return p.List[i]
   309 		return p.List[i]
   303 	}
   310 	}
   304 	return pref.SourceLocation{}
   311 	return protoreflect.SourceLocation{}
   305 }
   312 }
   306 func (p *SourceLocations) ByPath(path pref.SourcePath) pref.SourceLocation {
   313 func (p *SourceLocations) ByPath(path protoreflect.SourcePath) protoreflect.SourceLocation {
   307 	return p.byKey(newPathKey(path))
   314 	return p.byKey(newPathKey(path))
   308 }
   315 }
   309 func (p *SourceLocations) ByDescriptor(desc pref.Descriptor) pref.SourceLocation {
   316 func (p *SourceLocations) ByDescriptor(desc protoreflect.Descriptor) protoreflect.SourceLocation {
   310 	if p.File != nil && desc != nil && p.File != desc.ParentFile() {
   317 	if p.File != nil && desc != nil && p.File != desc.ParentFile() {
   311 		return pref.SourceLocation{} // mismatching parent files
   318 		return protoreflect.SourceLocation{} // mismatching parent files
   312 	}
   319 	}
   313 	var pathArr [16]int32
   320 	var pathArr [16]int32
   314 	path := pathArr[:0]
   321 	path := pathArr[:0]
   315 	for {
   322 	for {
   316 		switch desc.(type) {
   323 		switch desc.(type) {
   317 		case pref.FileDescriptor:
   324 		case protoreflect.FileDescriptor:
   318 			// Reverse the path since it was constructed in reverse.
   325 			// Reverse the path since it was constructed in reverse.
   319 			for i, j := 0, len(path)-1; i < j; i, j = i+1, j-1 {
   326 			for i, j := 0, len(path)-1; i < j; i, j = i+1, j-1 {
   320 				path[i], path[j] = path[j], path[i]
   327 				path[i], path[j] = path[j], path[i]
   321 			}
   328 			}
   322 			return p.byKey(newPathKey(path))
   329 			return p.byKey(newPathKey(path))
   323 		case pref.MessageDescriptor:
   330 		case protoreflect.MessageDescriptor:
   324 			path = append(path, int32(desc.Index()))
   331 			path = append(path, int32(desc.Index()))
   325 			desc = desc.Parent()
   332 			desc = desc.Parent()
   326 			switch desc.(type) {
   333 			switch desc.(type) {
   327 			case pref.FileDescriptor:
   334 			case protoreflect.FileDescriptor:
   328 				path = append(path, int32(genid.FileDescriptorProto_MessageType_field_number))
   335 				path = append(path, int32(genid.FileDescriptorProto_MessageType_field_number))
   329 			case pref.MessageDescriptor:
   336 			case protoreflect.MessageDescriptor:
   330 				path = append(path, int32(genid.DescriptorProto_NestedType_field_number))
   337 				path = append(path, int32(genid.DescriptorProto_NestedType_field_number))
   331 			default:
   338 			default:
   332 				return pref.SourceLocation{}
   339 				return protoreflect.SourceLocation{}
   333 			}
   340 			}
   334 		case pref.FieldDescriptor:
   341 		case protoreflect.FieldDescriptor:
   335 			isExtension := desc.(pref.FieldDescriptor).IsExtension()
   342 			isExtension := desc.(protoreflect.FieldDescriptor).IsExtension()
   336 			path = append(path, int32(desc.Index()))
   343 			path = append(path, int32(desc.Index()))
   337 			desc = desc.Parent()
   344 			desc = desc.Parent()
   338 			if isExtension {
   345 			if isExtension {
   339 				switch desc.(type) {
   346 				switch desc.(type) {
   340 				case pref.FileDescriptor:
   347 				case protoreflect.FileDescriptor:
   341 					path = append(path, int32(genid.FileDescriptorProto_Extension_field_number))
   348 					path = append(path, int32(genid.FileDescriptorProto_Extension_field_number))
   342 				case pref.MessageDescriptor:
   349 				case protoreflect.MessageDescriptor:
   343 					path = append(path, int32(genid.DescriptorProto_Extension_field_number))
   350 					path = append(path, int32(genid.DescriptorProto_Extension_field_number))
   344 				default:
   351 				default:
   345 					return pref.SourceLocation{}
   352 					return protoreflect.SourceLocation{}
   346 				}
   353 				}
   347 			} else {
   354 			} else {
   348 				switch desc.(type) {
   355 				switch desc.(type) {
   349 				case pref.MessageDescriptor:
   356 				case protoreflect.MessageDescriptor:
   350 					path = append(path, int32(genid.DescriptorProto_Field_field_number))
   357 					path = append(path, int32(genid.DescriptorProto_Field_field_number))
   351 				default:
   358 				default:
   352 					return pref.SourceLocation{}
   359 					return protoreflect.SourceLocation{}
   353 				}
   360 				}
   354 			}
   361 			}
   355 		case pref.OneofDescriptor:
   362 		case protoreflect.OneofDescriptor:
   356 			path = append(path, int32(desc.Index()))
   363 			path = append(path, int32(desc.Index()))
   357 			desc = desc.Parent()
   364 			desc = desc.Parent()
   358 			switch desc.(type) {
   365 			switch desc.(type) {
   359 			case pref.MessageDescriptor:
   366 			case protoreflect.MessageDescriptor:
   360 				path = append(path, int32(genid.DescriptorProto_OneofDecl_field_number))
   367 				path = append(path, int32(genid.DescriptorProto_OneofDecl_field_number))
   361 			default:
   368 			default:
   362 				return pref.SourceLocation{}
   369 				return protoreflect.SourceLocation{}
   363 			}
   370 			}
   364 		case pref.EnumDescriptor:
   371 		case protoreflect.EnumDescriptor:
   365 			path = append(path, int32(desc.Index()))
   372 			path = append(path, int32(desc.Index()))
   366 			desc = desc.Parent()
   373 			desc = desc.Parent()
   367 			switch desc.(type) {
   374 			switch desc.(type) {
   368 			case pref.FileDescriptor:
   375 			case protoreflect.FileDescriptor:
   369 				path = append(path, int32(genid.FileDescriptorProto_EnumType_field_number))
   376 				path = append(path, int32(genid.FileDescriptorProto_EnumType_field_number))
   370 			case pref.MessageDescriptor:
   377 			case protoreflect.MessageDescriptor:
   371 				path = append(path, int32(genid.DescriptorProto_EnumType_field_number))
   378 				path = append(path, int32(genid.DescriptorProto_EnumType_field_number))
   372 			default:
   379 			default:
   373 				return pref.SourceLocation{}
   380 				return protoreflect.SourceLocation{}
   374 			}
   381 			}
   375 		case pref.EnumValueDescriptor:
   382 		case protoreflect.EnumValueDescriptor:
   376 			path = append(path, int32(desc.Index()))
   383 			path = append(path, int32(desc.Index()))
   377 			desc = desc.Parent()
   384 			desc = desc.Parent()
   378 			switch desc.(type) {
   385 			switch desc.(type) {
   379 			case pref.EnumDescriptor:
   386 			case protoreflect.EnumDescriptor:
   380 				path = append(path, int32(genid.EnumDescriptorProto_Value_field_number))
   387 				path = append(path, int32(genid.EnumDescriptorProto_Value_field_number))
   381 			default:
   388 			default:
   382 				return pref.SourceLocation{}
   389 				return protoreflect.SourceLocation{}
   383 			}
   390 			}
   384 		case pref.ServiceDescriptor:
   391 		case protoreflect.ServiceDescriptor:
   385 			path = append(path, int32(desc.Index()))
   392 			path = append(path, int32(desc.Index()))
   386 			desc = desc.Parent()
   393 			desc = desc.Parent()
   387 			switch desc.(type) {
   394 			switch desc.(type) {
   388 			case pref.FileDescriptor:
   395 			case protoreflect.FileDescriptor:
   389 				path = append(path, int32(genid.FileDescriptorProto_Service_field_number))
   396 				path = append(path, int32(genid.FileDescriptorProto_Service_field_number))
   390 			default:
   397 			default:
   391 				return pref.SourceLocation{}
   398 				return protoreflect.SourceLocation{}
   392 			}
   399 			}
   393 		case pref.MethodDescriptor:
   400 		case protoreflect.MethodDescriptor:
   394 			path = append(path, int32(desc.Index()))
   401 			path = append(path, int32(desc.Index()))
   395 			desc = desc.Parent()
   402 			desc = desc.Parent()
   396 			switch desc.(type) {
   403 			switch desc.(type) {
   397 			case pref.ServiceDescriptor:
   404 			case protoreflect.ServiceDescriptor:
   398 				path = append(path, int32(genid.ServiceDescriptorProto_Method_field_number))
   405 				path = append(path, int32(genid.ServiceDescriptorProto_Method_field_number))
   399 			default:
   406 			default:
   400 				return pref.SourceLocation{}
   407 				return protoreflect.SourceLocation{}
   401 			}
   408 			}
   402 		default:
   409 		default:
   403 			return pref.SourceLocation{}
   410 			return protoreflect.SourceLocation{}
   404 		}
   411 		}
   405 	}
   412 	}
   406 }
   413 }
   407 func (p *SourceLocations) lazyInit() *SourceLocations {
   414 func (p *SourceLocations) lazyInit() *SourceLocations {
   408 	p.once.Do(func() {
   415 	p.once.Do(func() {
   433 type pathKey struct {
   440 type pathKey struct {
   434 	arr [16]uint8 // first n-1 path segments; last element is the length
   441 	arr [16]uint8 // first n-1 path segments; last element is the length
   435 	str string    // used if the path does not fit in arr
   442 	str string    // used if the path does not fit in arr
   436 }
   443 }
   437 
   444 
   438 func newPathKey(p pref.SourcePath) (k pathKey) {
   445 func newPathKey(p protoreflect.SourcePath) (k pathKey) {
   439 	if len(p) < len(k.arr) {
   446 	if len(p) < len(k.arr) {
   440 		for i, ps := range p {
   447 		for i, ps := range p {
   441 			if ps < 0 || math.MaxUint8 <= ps {
   448 			if ps < 0 || math.MaxUint8 <= ps {
   442 				return pathKey{str: p.String()}
   449 				return pathKey{str: p.String()}
   443 			}
   450 			}