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