khenaidoo | 106c61a | 2021-08-11 18:05:46 -0400 | [diff] [blame] | 1 | // Copyright 2019 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package filedesc |
| 6 | |
| 7 | import ( |
| 8 | "google.golang.org/protobuf/internal/descopts" |
| 9 | "google.golang.org/protobuf/internal/pragma" |
| 10 | pref "google.golang.org/protobuf/reflect/protoreflect" |
| 11 | ) |
| 12 | |
| 13 | var ( |
| 14 | emptyNames = new(Names) |
| 15 | emptyEnumRanges = new(EnumRanges) |
| 16 | emptyFieldRanges = new(FieldRanges) |
| 17 | emptyFieldNumbers = new(FieldNumbers) |
| 18 | emptySourceLocations = new(SourceLocations) |
| 19 | |
| 20 | emptyFiles = new(FileImports) |
| 21 | emptyMessages = new(Messages) |
| 22 | emptyFields = new(Fields) |
| 23 | emptyOneofs = new(Oneofs) |
| 24 | emptyEnums = new(Enums) |
| 25 | emptyEnumValues = new(EnumValues) |
| 26 | emptyExtensions = new(Extensions) |
| 27 | emptyServices = new(Services) |
| 28 | ) |
| 29 | |
| 30 | // PlaceholderFile is a placeholder, representing only the file path. |
| 31 | type PlaceholderFile string |
| 32 | |
| 33 | func (f PlaceholderFile) ParentFile() pref.FileDescriptor { return f } |
| 34 | func (f PlaceholderFile) Parent() pref.Descriptor { return nil } |
| 35 | func (f PlaceholderFile) Index() int { return 0 } |
| 36 | func (f PlaceholderFile) Syntax() pref.Syntax { return 0 } |
| 37 | func (f PlaceholderFile) Name() pref.Name { return "" } |
| 38 | func (f PlaceholderFile) FullName() pref.FullName { return "" } |
| 39 | func (f PlaceholderFile) IsPlaceholder() bool { return true } |
| 40 | func (f PlaceholderFile) Options() pref.ProtoMessage { return descopts.File } |
| 41 | func (f PlaceholderFile) Path() string { return string(f) } |
| 42 | func (f PlaceholderFile) Package() pref.FullName { return "" } |
| 43 | func (f PlaceholderFile) Imports() pref.FileImports { return emptyFiles } |
| 44 | func (f PlaceholderFile) Messages() pref.MessageDescriptors { return emptyMessages } |
| 45 | func (f PlaceholderFile) Enums() pref.EnumDescriptors { return emptyEnums } |
| 46 | func (f PlaceholderFile) Extensions() pref.ExtensionDescriptors { return emptyExtensions } |
| 47 | func (f PlaceholderFile) Services() pref.ServiceDescriptors { return emptyServices } |
| 48 | func (f PlaceholderFile) SourceLocations() pref.SourceLocations { return emptySourceLocations } |
| 49 | func (f PlaceholderFile) ProtoType(pref.FileDescriptor) { return } |
| 50 | func (f PlaceholderFile) ProtoInternal(pragma.DoNotImplement) { return } |
| 51 | |
| 52 | // PlaceholderEnum is a placeholder, representing only the full name. |
| 53 | type PlaceholderEnum pref.FullName |
| 54 | |
| 55 | func (e PlaceholderEnum) ParentFile() pref.FileDescriptor { return nil } |
| 56 | func (e PlaceholderEnum) Parent() pref.Descriptor { return nil } |
| 57 | func (e PlaceholderEnum) Index() int { return 0 } |
| 58 | func (e PlaceholderEnum) Syntax() pref.Syntax { return 0 } |
| 59 | func (e PlaceholderEnum) Name() pref.Name { return pref.FullName(e).Name() } |
| 60 | func (e PlaceholderEnum) FullName() pref.FullName { return pref.FullName(e) } |
| 61 | func (e PlaceholderEnum) IsPlaceholder() bool { return true } |
| 62 | func (e PlaceholderEnum) Options() pref.ProtoMessage { return descopts.Enum } |
| 63 | func (e PlaceholderEnum) Values() pref.EnumValueDescriptors { return emptyEnumValues } |
| 64 | func (e PlaceholderEnum) ReservedNames() pref.Names { return emptyNames } |
| 65 | func (e PlaceholderEnum) ReservedRanges() pref.EnumRanges { return emptyEnumRanges } |
| 66 | func (e PlaceholderEnum) ProtoType(pref.EnumDescriptor) { return } |
| 67 | func (e PlaceholderEnum) ProtoInternal(pragma.DoNotImplement) { return } |
| 68 | |
| 69 | // PlaceholderEnumValue is a placeholder, representing only the full name. |
| 70 | type PlaceholderEnumValue pref.FullName |
| 71 | |
| 72 | func (e PlaceholderEnumValue) ParentFile() pref.FileDescriptor { return nil } |
| 73 | func (e PlaceholderEnumValue) Parent() pref.Descriptor { return nil } |
| 74 | func (e PlaceholderEnumValue) Index() int { return 0 } |
| 75 | func (e PlaceholderEnumValue) Syntax() pref.Syntax { return 0 } |
| 76 | func (e PlaceholderEnumValue) Name() pref.Name { return pref.FullName(e).Name() } |
| 77 | func (e PlaceholderEnumValue) FullName() pref.FullName { return pref.FullName(e) } |
| 78 | func (e PlaceholderEnumValue) IsPlaceholder() bool { return true } |
| 79 | func (e PlaceholderEnumValue) Options() pref.ProtoMessage { return descopts.EnumValue } |
| 80 | func (e PlaceholderEnumValue) Number() pref.EnumNumber { return 0 } |
| 81 | func (e PlaceholderEnumValue) ProtoType(pref.EnumValueDescriptor) { return } |
| 82 | func (e PlaceholderEnumValue) ProtoInternal(pragma.DoNotImplement) { return } |
| 83 | |
| 84 | // PlaceholderMessage is a placeholder, representing only the full name. |
| 85 | type PlaceholderMessage pref.FullName |
| 86 | |
| 87 | func (m PlaceholderMessage) ParentFile() pref.FileDescriptor { return nil } |
| 88 | func (m PlaceholderMessage) Parent() pref.Descriptor { return nil } |
| 89 | func (m PlaceholderMessage) Index() int { return 0 } |
| 90 | func (m PlaceholderMessage) Syntax() pref.Syntax { return 0 } |
| 91 | func (m PlaceholderMessage) Name() pref.Name { return pref.FullName(m).Name() } |
| 92 | func (m PlaceholderMessage) FullName() pref.FullName { return pref.FullName(m) } |
| 93 | func (m PlaceholderMessage) IsPlaceholder() bool { return true } |
| 94 | func (m PlaceholderMessage) Options() pref.ProtoMessage { return descopts.Message } |
| 95 | func (m PlaceholderMessage) IsMapEntry() bool { return false } |
| 96 | func (m PlaceholderMessage) Fields() pref.FieldDescriptors { return emptyFields } |
| 97 | func (m PlaceholderMessage) Oneofs() pref.OneofDescriptors { return emptyOneofs } |
| 98 | func (m PlaceholderMessage) ReservedNames() pref.Names { return emptyNames } |
| 99 | func (m PlaceholderMessage) ReservedRanges() pref.FieldRanges { return emptyFieldRanges } |
| 100 | func (m PlaceholderMessage) RequiredNumbers() pref.FieldNumbers { return emptyFieldNumbers } |
| 101 | func (m PlaceholderMessage) ExtensionRanges() pref.FieldRanges { return emptyFieldRanges } |
| 102 | func (m PlaceholderMessage) ExtensionRangeOptions(int) pref.ProtoMessage { panic("index out of range") } |
| 103 | func (m PlaceholderMessage) Messages() pref.MessageDescriptors { return emptyMessages } |
| 104 | func (m PlaceholderMessage) Enums() pref.EnumDescriptors { return emptyEnums } |
| 105 | func (m PlaceholderMessage) Extensions() pref.ExtensionDescriptors { return emptyExtensions } |
| 106 | func (m PlaceholderMessage) ProtoType(pref.MessageDescriptor) { return } |
| 107 | func (m PlaceholderMessage) ProtoInternal(pragma.DoNotImplement) { return } |