placeholder.go 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. package filedesc
  5. import (
  6. "google.golang.org/protobuf/internal/descopts"
  7. "google.golang.org/protobuf/internal/pragma"
  8. "google.golang.org/protobuf/reflect/protoreflect"
  9. )
  10. var (
  11. emptyNames = new(Names)
  12. emptyEnumRanges = new(EnumRanges)
  13. emptyFieldRanges = new(FieldRanges)
  14. emptyFieldNumbers = new(FieldNumbers)
  15. emptySourceLocations = new(SourceLocations)
  16. emptyFiles = new(FileImports)
  17. emptyMessages = new(Messages)
  18. emptyFields = new(Fields)
  19. emptyOneofs = new(Oneofs)
  20. emptyEnums = new(Enums)
  21. emptyEnumValues = new(EnumValues)
  22. emptyExtensions = new(Extensions)
  23. emptyServices = new(Services)
  24. )
  25. // PlaceholderFile is a placeholder, representing only the file path.
  26. type PlaceholderFile string
  27. func (f PlaceholderFile) ParentFile() protoreflect.FileDescriptor { return f }
  28. func (f PlaceholderFile) Parent() protoreflect.Descriptor { return nil }
  29. func (f PlaceholderFile) Index() int { return 0 }
  30. func (f PlaceholderFile) Syntax() protoreflect.Syntax { return 0 }
  31. func (f PlaceholderFile) Name() protoreflect.Name { return "" }
  32. func (f PlaceholderFile) FullName() protoreflect.FullName { return "" }
  33. func (f PlaceholderFile) IsPlaceholder() bool { return true }
  34. func (f PlaceholderFile) Options() protoreflect.ProtoMessage { return descopts.File }
  35. func (f PlaceholderFile) Path() string { return string(f) }
  36. func (f PlaceholderFile) Package() protoreflect.FullName { return "" }
  37. func (f PlaceholderFile) Imports() protoreflect.FileImports { return emptyFiles }
  38. func (f PlaceholderFile) Messages() protoreflect.MessageDescriptors { return emptyMessages }
  39. func (f PlaceholderFile) Enums() protoreflect.EnumDescriptors { return emptyEnums }
  40. func (f PlaceholderFile) Extensions() protoreflect.ExtensionDescriptors { return emptyExtensions }
  41. func (f PlaceholderFile) Services() protoreflect.ServiceDescriptors { return emptyServices }
  42. func (f PlaceholderFile) SourceLocations() protoreflect.SourceLocations { return emptySourceLocations }
  43. func (f PlaceholderFile) ProtoType(protoreflect.FileDescriptor) { return }
  44. func (f PlaceholderFile) ProtoInternal(pragma.DoNotImplement) { return }
  45. // PlaceholderEnum is a placeholder, representing only the full name.
  46. type PlaceholderEnum protoreflect.FullName
  47. func (e PlaceholderEnum) ParentFile() protoreflect.FileDescriptor { return nil }
  48. func (e PlaceholderEnum) Parent() protoreflect.Descriptor { return nil }
  49. func (e PlaceholderEnum) Index() int { return 0 }
  50. func (e PlaceholderEnum) Syntax() protoreflect.Syntax { return 0 }
  51. func (e PlaceholderEnum) Name() protoreflect.Name { return protoreflect.FullName(e).Name() }
  52. func (e PlaceholderEnum) FullName() protoreflect.FullName { return protoreflect.FullName(e) }
  53. func (e PlaceholderEnum) IsPlaceholder() bool { return true }
  54. func (e PlaceholderEnum) Options() protoreflect.ProtoMessage { return descopts.Enum }
  55. func (e PlaceholderEnum) Values() protoreflect.EnumValueDescriptors { return emptyEnumValues }
  56. func (e PlaceholderEnum) ReservedNames() protoreflect.Names { return emptyNames }
  57. func (e PlaceholderEnum) ReservedRanges() protoreflect.EnumRanges { return emptyEnumRanges }
  58. func (e PlaceholderEnum) ProtoType(protoreflect.EnumDescriptor) { return }
  59. func (e PlaceholderEnum) ProtoInternal(pragma.DoNotImplement) { return }
  60. // PlaceholderEnumValue is a placeholder, representing only the full name.
  61. type PlaceholderEnumValue protoreflect.FullName
  62. func (e PlaceholderEnumValue) ParentFile() protoreflect.FileDescriptor { return nil }
  63. func (e PlaceholderEnumValue) Parent() protoreflect.Descriptor { return nil }
  64. func (e PlaceholderEnumValue) Index() int { return 0 }
  65. func (e PlaceholderEnumValue) Syntax() protoreflect.Syntax { return 0 }
  66. func (e PlaceholderEnumValue) Name() protoreflect.Name { return protoreflect.FullName(e).Name() }
  67. func (e PlaceholderEnumValue) FullName() protoreflect.FullName { return protoreflect.FullName(e) }
  68. func (e PlaceholderEnumValue) IsPlaceholder() bool { return true }
  69. func (e PlaceholderEnumValue) Options() protoreflect.ProtoMessage { return descopts.EnumValue }
  70. func (e PlaceholderEnumValue) Number() protoreflect.EnumNumber { return 0 }
  71. func (e PlaceholderEnumValue) ProtoType(protoreflect.EnumValueDescriptor) { return }
  72. func (e PlaceholderEnumValue) ProtoInternal(pragma.DoNotImplement) { return }
  73. // PlaceholderMessage is a placeholder, representing only the full name.
  74. type PlaceholderMessage protoreflect.FullName
  75. func (m PlaceholderMessage) ParentFile() protoreflect.FileDescriptor { return nil }
  76. func (m PlaceholderMessage) Parent() protoreflect.Descriptor { return nil }
  77. func (m PlaceholderMessage) Index() int { return 0 }
  78. func (m PlaceholderMessage) Syntax() protoreflect.Syntax { return 0 }
  79. func (m PlaceholderMessage) Name() protoreflect.Name { return protoreflect.FullName(m).Name() }
  80. func (m PlaceholderMessage) FullName() protoreflect.FullName { return protoreflect.FullName(m) }
  81. func (m PlaceholderMessage) IsPlaceholder() bool { return true }
  82. func (m PlaceholderMessage) Options() protoreflect.ProtoMessage { return descopts.Message }
  83. func (m PlaceholderMessage) IsMapEntry() bool { return false }
  84. func (m PlaceholderMessage) Fields() protoreflect.FieldDescriptors { return emptyFields }
  85. func (m PlaceholderMessage) Oneofs() protoreflect.OneofDescriptors { return emptyOneofs }
  86. func (m PlaceholderMessage) ReservedNames() protoreflect.Names { return emptyNames }
  87. func (m PlaceholderMessage) ReservedRanges() protoreflect.FieldRanges { return emptyFieldRanges }
  88. func (m PlaceholderMessage) RequiredNumbers() protoreflect.FieldNumbers { return emptyFieldNumbers }
  89. func (m PlaceholderMessage) ExtensionRanges() protoreflect.FieldRanges { return emptyFieldRanges }
  90. func (m PlaceholderMessage) ExtensionRangeOptions(int) protoreflect.ProtoMessage {
  91. panic("index out of range")
  92. }
  93. func (m PlaceholderMessage) Messages() protoreflect.MessageDescriptors { return emptyMessages }
  94. func (m PlaceholderMessage) Enums() protoreflect.EnumDescriptors { return emptyEnums }
  95. func (m PlaceholderMessage) Extensions() protoreflect.ExtensionDescriptors { return emptyExtensions }
  96. func (m PlaceholderMessage) ProtoType(protoreflect.MessageDescriptor) { return }
  97. func (m PlaceholderMessage) ProtoInternal(pragma.DoNotImplement) { return }