mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-04-10 06:44:15 +00:00
all: remove dead code
Change-Id: I1344d6afca9d3348db849c2b5f387ac18b80d2ba Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/189021 Reviewed-by: Damien Neil <dneil@google.com>
This commit is contained in:
parent
52ec1759a4
commit
e815d6a43b
@ -74,11 +74,10 @@ const (
|
||||
// patched to support unique build environments that impose restrictions
|
||||
// on the dependencies of generated source code.
|
||||
var (
|
||||
protoifacePackage goImportPath = protogen.GoImportPath("google.golang.org/protobuf/runtime/protoiface")
|
||||
protoimplPackage goImportPath = protogen.GoImportPath("google.golang.org/protobuf/runtime/protoimpl")
|
||||
protoreflectPackage goImportPath = protogen.GoImportPath("google.golang.org/protobuf/reflect/protoreflect")
|
||||
protoregistryPackage goImportPath = protogen.GoImportPath("google.golang.org/protobuf/reflect/protoregistry")
|
||||
prototypePackage goImportPath = protogen.GoImportPath("google.golang.org/protobuf/reflect/prototype")
|
||||
protoifacePackage goImportPath = protogen.GoImportPath("google.golang.org/protobuf/runtime/protoiface")
|
||||
protoimplPackage goImportPath = protogen.GoImportPath("google.golang.org/protobuf/runtime/protoimpl")
|
||||
protoreflectPackage goImportPath = protogen.GoImportPath("google.golang.org/protobuf/reflect/protoreflect")
|
||||
prototypePackage goImportPath = protogen.GoImportPath("google.golang.org/protobuf/reflect/prototype")
|
||||
)
|
||||
|
||||
type goImportPath interface {
|
||||
|
@ -10,12 +10,9 @@ import (
|
||||
"sort"
|
||||
|
||||
"google.golang.org/protobuf/internal/encoding/wire"
|
||||
"google.golang.org/protobuf/proto"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
var protoMessageType = reflect.TypeOf((*proto.Message)(nil)).Elem()
|
||||
|
||||
type mapInfo struct {
|
||||
goType reflect.Type
|
||||
keyWiretag uint64
|
||||
|
@ -85,8 +85,6 @@ var (
|
||||
|
||||
var legacyEnumDescCache sync.Map // map[reflect.Type]protoreflect.EnumDescriptor
|
||||
|
||||
var legacyEnumNumberType = reflect.TypeOf(pref.EnumNumber(0))
|
||||
|
||||
// LegacyLoadEnumDesc returns an EnumDescriptor derived from the Go type,
|
||||
// which must be an int32 kind and not implement the v2 API already.
|
||||
//
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
"reflect"
|
||||
"strings"
|
||||
"sync"
|
||||
"unicode"
|
||||
|
||||
"google.golang.org/protobuf/internal/descopts"
|
||||
ptag "google.golang.org/protobuf/internal/encoding/tag"
|
||||
@ -279,23 +278,3 @@ type placeholderEnumValues struct {
|
||||
func (placeholderEnumValues) ByNumber(n pref.EnumNumber) pref.EnumValueDescriptor {
|
||||
return filedesc.PlaceholderEnumValue(pref.FullName(fmt.Sprintf("UNKNOWN_%d", n)))
|
||||
}
|
||||
|
||||
// aberrantMapEntryName derives the name for a map entry message.
|
||||
// See protoc v3.8.0: src/google/protobuf/descriptor.cc:254-276,6057
|
||||
func aberrantMapEntryName(s pref.Name) pref.Name {
|
||||
var b []byte
|
||||
upperNext := true
|
||||
for _, c := range s {
|
||||
switch {
|
||||
case c == '_':
|
||||
upperNext = true
|
||||
case upperNext:
|
||||
b = append(b, byte(unicode.ToUpper(c)))
|
||||
upperNext = false
|
||||
default:
|
||||
b = append(b, byte(c))
|
||||
}
|
||||
}
|
||||
b = append(b, "Entry"...)
|
||||
return pref.Name(b)
|
||||
}
|
||||
|
@ -64,8 +64,6 @@ type reflectMessageInfo struct {
|
||||
// exporting the requested field (e.g., already exported).
|
||||
type exporter func(v interface{}, i int) interface{}
|
||||
|
||||
var prefMessageType = reflect.TypeOf((*pref.Message)(nil)).Elem()
|
||||
|
||||
// getMessageInfo returns the MessageInfo for any message type that
|
||||
// is generated by our implementation of protoc-gen-go (for v2 and on).
|
||||
// If it is unable to obtain a MessageInfo, it returns nil.
|
||||
|
@ -442,12 +442,6 @@ func makeOneofInfo(od pref.OneofDescriptor, fs reflect.StructField, x exporter,
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
enumIfaceV2 = reflect.TypeOf((*pref.Enum)(nil)).Elem()
|
||||
messageIfaceV1 = reflect.TypeOf((*piface.MessageV1)(nil)).Elem()
|
||||
messageIfaceV2 = reflect.TypeOf((*pref.ProtoMessage)(nil)).Elem()
|
||||
)
|
||||
|
||||
// defaultValueOf returns the default value for the field.
|
||||
func defaultValueOf(fd pref.FieldDescriptor) pref.Value {
|
||||
if fd == nil {
|
||||
|
@ -5,12 +5,8 @@
|
||||
package proto
|
||||
|
||||
import (
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
// Message is the top-level interface that all messages must implement.
|
||||
type Message = protoreflect.ProtoMessage
|
||||
|
||||
// errInternalNoFast indicates that fast-path operations are not available for a message.
|
||||
var errInternalNoFast = errors.New("BUG: internal error (errInternalNoFast)")
|
||||
|
@ -131,7 +131,7 @@ func newFile(fd *descriptorpb.FileDescriptorProto, r Resolver, opts ...option) (
|
||||
}
|
||||
imps[imp.Path()] = true
|
||||
}
|
||||
for i, _ := range fd.GetDependency() {
|
||||
for i := range fd.GetDependency() {
|
||||
imp := &f.L2.Imports[i]
|
||||
imps.importPublic(imp.Imports())
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ func validateMessageDeclarations(ms []filedesc.Message, mds []*descriptorpb.Desc
|
||||
}
|
||||
}
|
||||
}
|
||||
for j, _ := range md.GetOneofDecl() {
|
||||
for j := range md.GetOneofDecl() {
|
||||
o := &m.L2.Oneofs.List[j]
|
||||
if o.Fields().Len() == 0 {
|
||||
return errors.New("message oneof %q must contain at least one field declaration", o.FullName())
|
||||
|
@ -499,8 +499,7 @@ func (r *Types) FindEnumByName(enum protoreflect.FullName) (protoreflect.EnumTyp
|
||||
if r == nil {
|
||||
return nil, NotFound
|
||||
}
|
||||
v, _ := r.typesByName[enum]
|
||||
if v != nil {
|
||||
if v := r.typesByName[enum]; v != nil {
|
||||
if et, _ := v.(protoreflect.EnumType); et != nil {
|
||||
return et, nil
|
||||
}
|
||||
@ -531,8 +530,7 @@ func (r *Types) FindMessageByURL(url string) (protoreflect.MessageType, error) {
|
||||
message = message[i+len("/"):]
|
||||
}
|
||||
|
||||
v, _ := r.typesByName[message]
|
||||
if v != nil {
|
||||
if v := r.typesByName[message]; v != nil {
|
||||
if mt, _ := v.(protoreflect.MessageType); mt != nil {
|
||||
return mt, nil
|
||||
}
|
||||
@ -551,8 +549,7 @@ func (r *Types) FindExtensionByName(field protoreflect.FullName) (protoreflect.E
|
||||
if r == nil {
|
||||
return nil, NotFound
|
||||
}
|
||||
v, _ := r.typesByName[field]
|
||||
if v != nil {
|
||||
if v := r.typesByName[field]; v != nil {
|
||||
if xt, _ := v.(protoreflect.ExtensionType); xt != nil {
|
||||
return xt, nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user