blob: 28240ebc5c4abfb96263020d1c7dd87eadc51415 [file] [log] [blame]
Naveen Sampath04696f72022-06-13 15:19:14 +05301// 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
5package filedesc
6
7import (
8 "google.golang.org/protobuf/internal/descopts"
9 "google.golang.org/protobuf/internal/pragma"
Akash Reddy Kankanala105581b2024-09-11 05:20:38 +053010 "google.golang.org/protobuf/reflect/protoreflect"
Naveen Sampath04696f72022-06-13 15:19:14 +053011)
12
13var (
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.
31type PlaceholderFile string
32
Akash Reddy Kankanala105581b2024-09-11 05:20:38 +053033func (f PlaceholderFile) ParentFile() protoreflect.FileDescriptor { return f }
34func (f PlaceholderFile) Parent() protoreflect.Descriptor { return nil }
35func (f PlaceholderFile) Index() int { return 0 }
36func (f PlaceholderFile) Syntax() protoreflect.Syntax { return 0 }
37func (f PlaceholderFile) Name() protoreflect.Name { return "" }
38func (f PlaceholderFile) FullName() protoreflect.FullName { return "" }
39func (f PlaceholderFile) IsPlaceholder() bool { return true }
40func (f PlaceholderFile) Options() protoreflect.ProtoMessage { return descopts.File }
41func (f PlaceholderFile) Path() string { return string(f) }
42func (f PlaceholderFile) Package() protoreflect.FullName { return "" }
43func (f PlaceholderFile) Imports() protoreflect.FileImports { return emptyFiles }
44func (f PlaceholderFile) Messages() protoreflect.MessageDescriptors { return emptyMessages }
45func (f PlaceholderFile) Enums() protoreflect.EnumDescriptors { return emptyEnums }
46func (f PlaceholderFile) Extensions() protoreflect.ExtensionDescriptors { return emptyExtensions }
47func (f PlaceholderFile) Services() protoreflect.ServiceDescriptors { return emptyServices }
48func (f PlaceholderFile) SourceLocations() protoreflect.SourceLocations { return emptySourceLocations }
49func (f PlaceholderFile) ProtoType(protoreflect.FileDescriptor) { return }
50func (f PlaceholderFile) ProtoInternal(pragma.DoNotImplement) { return }
Naveen Sampath04696f72022-06-13 15:19:14 +053051
52// PlaceholderEnum is a placeholder, representing only the full name.
Akash Reddy Kankanala105581b2024-09-11 05:20:38 +053053type PlaceholderEnum protoreflect.FullName
Naveen Sampath04696f72022-06-13 15:19:14 +053054
Akash Reddy Kankanala105581b2024-09-11 05:20:38 +053055func (e PlaceholderEnum) ParentFile() protoreflect.FileDescriptor { return nil }
56func (e PlaceholderEnum) Parent() protoreflect.Descriptor { return nil }
57func (e PlaceholderEnum) Index() int { return 0 }
58func (e PlaceholderEnum) Syntax() protoreflect.Syntax { return 0 }
59func (e PlaceholderEnum) Name() protoreflect.Name { return protoreflect.FullName(e).Name() }
60func (e PlaceholderEnum) FullName() protoreflect.FullName { return protoreflect.FullName(e) }
61func (e PlaceholderEnum) IsPlaceholder() bool { return true }
62func (e PlaceholderEnum) Options() protoreflect.ProtoMessage { return descopts.Enum }
63func (e PlaceholderEnum) Values() protoreflect.EnumValueDescriptors { return emptyEnumValues }
64func (e PlaceholderEnum) ReservedNames() protoreflect.Names { return emptyNames }
65func (e PlaceholderEnum) ReservedRanges() protoreflect.EnumRanges { return emptyEnumRanges }
66func (e PlaceholderEnum) ProtoType(protoreflect.EnumDescriptor) { return }
67func (e PlaceholderEnum) ProtoInternal(pragma.DoNotImplement) { return }
Naveen Sampath04696f72022-06-13 15:19:14 +053068
69// PlaceholderEnumValue is a placeholder, representing only the full name.
Akash Reddy Kankanala105581b2024-09-11 05:20:38 +053070type PlaceholderEnumValue protoreflect.FullName
Naveen Sampath04696f72022-06-13 15:19:14 +053071
Akash Reddy Kankanala105581b2024-09-11 05:20:38 +053072func (e PlaceholderEnumValue) ParentFile() protoreflect.FileDescriptor { return nil }
73func (e PlaceholderEnumValue) Parent() protoreflect.Descriptor { return nil }
74func (e PlaceholderEnumValue) Index() int { return 0 }
75func (e PlaceholderEnumValue) Syntax() protoreflect.Syntax { return 0 }
76func (e PlaceholderEnumValue) Name() protoreflect.Name { return protoreflect.FullName(e).Name() }
77func (e PlaceholderEnumValue) FullName() protoreflect.FullName { return protoreflect.FullName(e) }
78func (e PlaceholderEnumValue) IsPlaceholder() bool { return true }
79func (e PlaceholderEnumValue) Options() protoreflect.ProtoMessage { return descopts.EnumValue }
80func (e PlaceholderEnumValue) Number() protoreflect.EnumNumber { return 0 }
81func (e PlaceholderEnumValue) ProtoType(protoreflect.EnumValueDescriptor) { return }
82func (e PlaceholderEnumValue) ProtoInternal(pragma.DoNotImplement) { return }
Naveen Sampath04696f72022-06-13 15:19:14 +053083
84// PlaceholderMessage is a placeholder, representing only the full name.
Akash Reddy Kankanala105581b2024-09-11 05:20:38 +053085type PlaceholderMessage protoreflect.FullName
Naveen Sampath04696f72022-06-13 15:19:14 +053086
Akash Reddy Kankanala105581b2024-09-11 05:20:38 +053087func (m PlaceholderMessage) ParentFile() protoreflect.FileDescriptor { return nil }
88func (m PlaceholderMessage) Parent() protoreflect.Descriptor { return nil }
89func (m PlaceholderMessage) Index() int { return 0 }
90func (m PlaceholderMessage) Syntax() protoreflect.Syntax { return 0 }
91func (m PlaceholderMessage) Name() protoreflect.Name { return protoreflect.FullName(m).Name() }
92func (m PlaceholderMessage) FullName() protoreflect.FullName { return protoreflect.FullName(m) }
93func (m PlaceholderMessage) IsPlaceholder() bool { return true }
94func (m PlaceholderMessage) Options() protoreflect.ProtoMessage { return descopts.Message }
95func (m PlaceholderMessage) IsMapEntry() bool { return false }
96func (m PlaceholderMessage) Fields() protoreflect.FieldDescriptors { return emptyFields }
97func (m PlaceholderMessage) Oneofs() protoreflect.OneofDescriptors { return emptyOneofs }
98func (m PlaceholderMessage) ReservedNames() protoreflect.Names { return emptyNames }
99func (m PlaceholderMessage) ReservedRanges() protoreflect.FieldRanges { return emptyFieldRanges }
100func (m PlaceholderMessage) RequiredNumbers() protoreflect.FieldNumbers { return emptyFieldNumbers }
101func (m PlaceholderMessage) ExtensionRanges() protoreflect.FieldRanges { return emptyFieldRanges }
102func (m PlaceholderMessage) ExtensionRangeOptions(int) protoreflect.ProtoMessage {
103 panic("index out of range")
104}
105func (m PlaceholderMessage) Messages() protoreflect.MessageDescriptors { return emptyMessages }
106func (m PlaceholderMessage) Enums() protoreflect.EnumDescriptors { return emptyEnums }
107func (m PlaceholderMessage) Extensions() protoreflect.ExtensionDescriptors { return emptyExtensions }
108func (m PlaceholderMessage) ProtoType(protoreflect.MessageDescriptor) { return }
109func (m PlaceholderMessage) ProtoInternal(pragma.DoNotImplement) { return }