placeholder.go (7103B)
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 "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() protoreflect.FileDescriptor { return f } 34 func (f PlaceholderFile) Parent() protoreflect.Descriptor { return nil } 35 func (f PlaceholderFile) Index() int { return 0 } 36 func (f PlaceholderFile) Syntax() protoreflect.Syntax { return 0 } 37 func (f PlaceholderFile) Name() protoreflect.Name { return "" } 38 func (f PlaceholderFile) FullName() protoreflect.FullName { return "" } 39 func (f PlaceholderFile) IsPlaceholder() bool { return true } 40 func (f PlaceholderFile) Options() protoreflect.ProtoMessage { return descopts.File } 41 func (f PlaceholderFile) Path() string { return string(f) } 42 func (f PlaceholderFile) Package() protoreflect.FullName { return "" } 43 func (f PlaceholderFile) Imports() protoreflect.FileImports { return emptyFiles } 44 func (f PlaceholderFile) Messages() protoreflect.MessageDescriptors { return emptyMessages } 45 func (f PlaceholderFile) Enums() protoreflect.EnumDescriptors { return emptyEnums } 46 func (f PlaceholderFile) Extensions() protoreflect.ExtensionDescriptors { return emptyExtensions } 47 func (f PlaceholderFile) Services() protoreflect.ServiceDescriptors { return emptyServices } 48 func (f PlaceholderFile) SourceLocations() protoreflect.SourceLocations { return emptySourceLocations } 49 func (f PlaceholderFile) ProtoType(protoreflect.FileDescriptor) { return } 50 func (f PlaceholderFile) ProtoInternal(pragma.DoNotImplement) { return } 51 52 // PlaceholderEnum is a placeholder, representing only the full name. 53 type PlaceholderEnum protoreflect.FullName 54 55 func (e PlaceholderEnum) ParentFile() protoreflect.FileDescriptor { return nil } 56 func (e PlaceholderEnum) Parent() protoreflect.Descriptor { return nil } 57 func (e PlaceholderEnum) Index() int { return 0 } 58 func (e PlaceholderEnum) Syntax() protoreflect.Syntax { return 0 } 59 func (e PlaceholderEnum) Name() protoreflect.Name { return protoreflect.FullName(e).Name() } 60 func (e PlaceholderEnum) FullName() protoreflect.FullName { return protoreflect.FullName(e) } 61 func (e PlaceholderEnum) IsPlaceholder() bool { return true } 62 func (e PlaceholderEnum) Options() protoreflect.ProtoMessage { return descopts.Enum } 63 func (e PlaceholderEnum) Values() protoreflect.EnumValueDescriptors { return emptyEnumValues } 64 func (e PlaceholderEnum) ReservedNames() protoreflect.Names { return emptyNames } 65 func (e PlaceholderEnum) ReservedRanges() protoreflect.EnumRanges { return emptyEnumRanges } 66 func (e PlaceholderEnum) ProtoType(protoreflect.EnumDescriptor) { return } 67 func (e PlaceholderEnum) ProtoInternal(pragma.DoNotImplement) { return } 68 69 // PlaceholderEnumValue is a placeholder, representing only the full name. 70 type PlaceholderEnumValue protoreflect.FullName 71 72 func (e PlaceholderEnumValue) ParentFile() protoreflect.FileDescriptor { return nil } 73 func (e PlaceholderEnumValue) Parent() protoreflect.Descriptor { return nil } 74 func (e PlaceholderEnumValue) Index() int { return 0 } 75 func (e PlaceholderEnumValue) Syntax() protoreflect.Syntax { return 0 } 76 func (e PlaceholderEnumValue) Name() protoreflect.Name { return protoreflect.FullName(e).Name() } 77 func (e PlaceholderEnumValue) FullName() protoreflect.FullName { return protoreflect.FullName(e) } 78 func (e PlaceholderEnumValue) IsPlaceholder() bool { return true } 79 func (e PlaceholderEnumValue) Options() protoreflect.ProtoMessage { return descopts.EnumValue } 80 func (e PlaceholderEnumValue) Number() protoreflect.EnumNumber { return 0 } 81 func (e PlaceholderEnumValue) ProtoType(protoreflect.EnumValueDescriptor) { return } 82 func (e PlaceholderEnumValue) ProtoInternal(pragma.DoNotImplement) { return } 83 84 // PlaceholderMessage is a placeholder, representing only the full name. 85 type PlaceholderMessage protoreflect.FullName 86 87 func (m PlaceholderMessage) ParentFile() protoreflect.FileDescriptor { return nil } 88 func (m PlaceholderMessage) Parent() protoreflect.Descriptor { return nil } 89 func (m PlaceholderMessage) Index() int { return 0 } 90 func (m PlaceholderMessage) Syntax() protoreflect.Syntax { return 0 } 91 func (m PlaceholderMessage) Name() protoreflect.Name { return protoreflect.FullName(m).Name() } 92 func (m PlaceholderMessage) FullName() protoreflect.FullName { return protoreflect.FullName(m) } 93 func (m PlaceholderMessage) IsPlaceholder() bool { return true } 94 func (m PlaceholderMessage) Options() protoreflect.ProtoMessage { return descopts.Message } 95 func (m PlaceholderMessage) IsMapEntry() bool { return false } 96 func (m PlaceholderMessage) Fields() protoreflect.FieldDescriptors { return emptyFields } 97 func (m PlaceholderMessage) Oneofs() protoreflect.OneofDescriptors { return emptyOneofs } 98 func (m PlaceholderMessage) ReservedNames() protoreflect.Names { return emptyNames } 99 func (m PlaceholderMessage) ReservedRanges() protoreflect.FieldRanges { return emptyFieldRanges } 100 func (m PlaceholderMessage) RequiredNumbers() protoreflect.FieldNumbers { return emptyFieldNumbers } 101 func (m PlaceholderMessage) ExtensionRanges() protoreflect.FieldRanges { return emptyFieldRanges } 102 func (m PlaceholderMessage) ExtensionRangeOptions(int) protoreflect.ProtoMessage { 103 panic("index out of range") 104 } 105 func (m PlaceholderMessage) Messages() protoreflect.MessageDescriptors { return emptyMessages } 106 func (m PlaceholderMessage) Enums() protoreflect.EnumDescriptors { return emptyEnums } 107 func (m PlaceholderMessage) Extensions() protoreflect.ExtensionDescriptors { return emptyExtensions } 108 func (m PlaceholderMessage) ProtoType(protoreflect.MessageDescriptor) { return } 109 func (m PlaceholderMessage) ProtoInternal(pragma.DoNotImplement) { return }