feat: implement copilot mode
This commit is contained in:
		
							
								
								
									
										41
									
								
								vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										41
									
								
								vendor/google.golang.org/protobuf/reflect/protoreflect/source_gen.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -35,6 +35,8 @@ func (p *SourcePath) appendFileDescriptorProto(b []byte) []byte {
 | 
			
		||||
		b = p.appendSingularField(b, "source_code_info", (*SourcePath).appendSourceCodeInfo)
 | 
			
		||||
	case 12:
 | 
			
		||||
		b = p.appendSingularField(b, "syntax", nil)
 | 
			
		||||
	case 13:
 | 
			
		||||
		b = p.appendSingularField(b, "edition", nil)
 | 
			
		||||
	}
 | 
			
		||||
	return b
 | 
			
		||||
}
 | 
			
		||||
@@ -236,6 +238,8 @@ func (p *SourcePath) appendMessageOptions(b []byte) []byte {
 | 
			
		||||
		b = p.appendSingularField(b, "deprecated", nil)
 | 
			
		||||
	case 7:
 | 
			
		||||
		b = p.appendSingularField(b, "map_entry", nil)
 | 
			
		||||
	case 11:
 | 
			
		||||
		b = p.appendSingularField(b, "deprecated_legacy_json_field_conflicts", nil)
 | 
			
		||||
	case 999:
 | 
			
		||||
		b = p.appendRepeatedField(b, "uninterpreted_option", (*SourcePath).appendUninterpretedOption)
 | 
			
		||||
	}
 | 
			
		||||
@@ -279,6 +283,8 @@ func (p *SourcePath) appendEnumOptions(b []byte) []byte {
 | 
			
		||||
		b = p.appendSingularField(b, "allow_alias", nil)
 | 
			
		||||
	case 3:
 | 
			
		||||
		b = p.appendSingularField(b, "deprecated", nil)
 | 
			
		||||
	case 6:
 | 
			
		||||
		b = p.appendSingularField(b, "deprecated_legacy_json_field_conflicts", nil)
 | 
			
		||||
	case 999:
 | 
			
		||||
		b = p.appendRepeatedField(b, "uninterpreted_option", (*SourcePath).appendUninterpretedOption)
 | 
			
		||||
	}
 | 
			
		||||
@@ -345,10 +351,20 @@ func (p *SourcePath) appendFieldOptions(b []byte) []byte {
 | 
			
		||||
		b = p.appendSingularField(b, "jstype", nil)
 | 
			
		||||
	case 5:
 | 
			
		||||
		b = p.appendSingularField(b, "lazy", nil)
 | 
			
		||||
	case 15:
 | 
			
		||||
		b = p.appendSingularField(b, "unverified_lazy", nil)
 | 
			
		||||
	case 3:
 | 
			
		||||
		b = p.appendSingularField(b, "deprecated", nil)
 | 
			
		||||
	case 10:
 | 
			
		||||
		b = p.appendSingularField(b, "weak", nil)
 | 
			
		||||
	case 16:
 | 
			
		||||
		b = p.appendSingularField(b, "debug_redact", nil)
 | 
			
		||||
	case 17:
 | 
			
		||||
		b = p.appendSingularField(b, "retention", nil)
 | 
			
		||||
	case 18:
 | 
			
		||||
		b = p.appendSingularField(b, "target", nil)
 | 
			
		||||
	case 19:
 | 
			
		||||
		b = p.appendRepeatedField(b, "targets", nil)
 | 
			
		||||
	case 999:
 | 
			
		||||
		b = p.appendRepeatedField(b, "uninterpreted_option", (*SourcePath).appendUninterpretedOption)
 | 
			
		||||
	}
 | 
			
		||||
@@ -404,6 +420,10 @@ func (p *SourcePath) appendExtensionRangeOptions(b []byte) []byte {
 | 
			
		||||
	switch (*p)[0] {
 | 
			
		||||
	case 999:
 | 
			
		||||
		b = p.appendRepeatedField(b, "uninterpreted_option", (*SourcePath).appendUninterpretedOption)
 | 
			
		||||
	case 2:
 | 
			
		||||
		b = p.appendRepeatedField(b, "declaration", (*SourcePath).appendExtensionRangeOptions_Declaration)
 | 
			
		||||
	case 3:
 | 
			
		||||
		b = p.appendSingularField(b, "verification", nil)
 | 
			
		||||
	}
 | 
			
		||||
	return b
 | 
			
		||||
}
 | 
			
		||||
@@ -459,3 +479,24 @@ func (p *SourcePath) appendUninterpretedOption_NamePart(b []byte) []byte {
 | 
			
		||||
	}
 | 
			
		||||
	return b
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (p *SourcePath) appendExtensionRangeOptions_Declaration(b []byte) []byte {
 | 
			
		||||
	if len(*p) == 0 {
 | 
			
		||||
		return b
 | 
			
		||||
	}
 | 
			
		||||
	switch (*p)[0] {
 | 
			
		||||
	case 1:
 | 
			
		||||
		b = p.appendSingularField(b, "number", nil)
 | 
			
		||||
	case 2:
 | 
			
		||||
		b = p.appendSingularField(b, "full_name", nil)
 | 
			
		||||
	case 3:
 | 
			
		||||
		b = p.appendSingularField(b, "type", nil)
 | 
			
		||||
	case 4:
 | 
			
		||||
		b = p.appendSingularField(b, "is_repeated", nil)
 | 
			
		||||
	case 5:
 | 
			
		||||
		b = p.appendSingularField(b, "reserved", nil)
 | 
			
		||||
	case 6:
 | 
			
		||||
		b = p.appendSingularField(b, "repeated", nil)
 | 
			
		||||
	}
 | 
			
		||||
	return b
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								vendor/google.golang.org/protobuf/reflect/protoreflect/value.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/google.golang.org/protobuf/reflect/protoreflect/value.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -148,7 +148,7 @@ type Message interface {
 | 
			
		||||
	// be preserved in marshaling or other operations.
 | 
			
		||||
	IsValid() bool
 | 
			
		||||
 | 
			
		||||
	// ProtoMethods returns optional fast-path implementions of various operations.
 | 
			
		||||
	// ProtoMethods returns optional fast-path implementations of various operations.
 | 
			
		||||
	// This method may return nil.
 | 
			
		||||
	//
 | 
			
		||||
	// The returned methods type is identical to
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										168
									
								
								vendor/google.golang.org/protobuf/reflect/protoreflect/value_equal.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										168
									
								
								vendor/google.golang.org/protobuf/reflect/protoreflect/value_equal.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,168 @@
 | 
			
		||||
// Copyright 2022 The Go Authors. All rights reserved.
 | 
			
		||||
// Use of this source code is governed by a BSD-style
 | 
			
		||||
// license that can be found in the LICENSE file.
 | 
			
		||||
 | 
			
		||||
package protoreflect
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"math"
 | 
			
		||||
	"reflect"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/protobuf/encoding/protowire"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Equal reports whether v1 and v2 are recursively equal.
 | 
			
		||||
//
 | 
			
		||||
//   - Values of different types are always unequal.
 | 
			
		||||
//
 | 
			
		||||
//   - Bytes values are equal if they contain identical bytes.
 | 
			
		||||
//     Empty bytes (regardless of nil-ness) are considered equal.
 | 
			
		||||
//
 | 
			
		||||
//   - Floating point values are equal if they contain the same value.
 | 
			
		||||
//     Unlike the == operator, a NaN is equal to another NaN.
 | 
			
		||||
//
 | 
			
		||||
//   - Enums are equal if they contain the same number.
 | 
			
		||||
//     Since Value does not contain an enum descriptor,
 | 
			
		||||
//     enum values do not consider the type of the enum.
 | 
			
		||||
//
 | 
			
		||||
//   - Other scalar values are equal if they contain the same value.
 | 
			
		||||
//
 | 
			
		||||
//   - Message values are equal if they belong to the same message descriptor,
 | 
			
		||||
//     have the same set of populated known and extension field values,
 | 
			
		||||
//     and the same set of unknown fields values.
 | 
			
		||||
//
 | 
			
		||||
//   - Lists are equal if they are the same length and
 | 
			
		||||
//     each corresponding element is equal.
 | 
			
		||||
//
 | 
			
		||||
//   - Maps are equal if they have the same set of keys and
 | 
			
		||||
//     the corresponding value for each key is equal.
 | 
			
		||||
func (v1 Value) Equal(v2 Value) bool {
 | 
			
		||||
	return equalValue(v1, v2)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func equalValue(x, y Value) bool {
 | 
			
		||||
	eqType := x.typ == y.typ
 | 
			
		||||
	switch x.typ {
 | 
			
		||||
	case nilType:
 | 
			
		||||
		return eqType
 | 
			
		||||
	case boolType:
 | 
			
		||||
		return eqType && x.Bool() == y.Bool()
 | 
			
		||||
	case int32Type, int64Type:
 | 
			
		||||
		return eqType && x.Int() == y.Int()
 | 
			
		||||
	case uint32Type, uint64Type:
 | 
			
		||||
		return eqType && x.Uint() == y.Uint()
 | 
			
		||||
	case float32Type, float64Type:
 | 
			
		||||
		return eqType && equalFloat(x.Float(), y.Float())
 | 
			
		||||
	case stringType:
 | 
			
		||||
		return eqType && x.String() == y.String()
 | 
			
		||||
	case bytesType:
 | 
			
		||||
		return eqType && bytes.Equal(x.Bytes(), y.Bytes())
 | 
			
		||||
	case enumType:
 | 
			
		||||
		return eqType && x.Enum() == y.Enum()
 | 
			
		||||
	default:
 | 
			
		||||
		switch x := x.Interface().(type) {
 | 
			
		||||
		case Message:
 | 
			
		||||
			y, ok := y.Interface().(Message)
 | 
			
		||||
			return ok && equalMessage(x, y)
 | 
			
		||||
		case List:
 | 
			
		||||
			y, ok := y.Interface().(List)
 | 
			
		||||
			return ok && equalList(x, y)
 | 
			
		||||
		case Map:
 | 
			
		||||
			y, ok := y.Interface().(Map)
 | 
			
		||||
			return ok && equalMap(x, y)
 | 
			
		||||
		default:
 | 
			
		||||
			panic(fmt.Sprintf("unknown type: %T", x))
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// equalFloat compares two floats, where NaNs are treated as equal.
 | 
			
		||||
func equalFloat(x, y float64) bool {
 | 
			
		||||
	if math.IsNaN(x) || math.IsNaN(y) {
 | 
			
		||||
		return math.IsNaN(x) && math.IsNaN(y)
 | 
			
		||||
	}
 | 
			
		||||
	return x == y
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// equalMessage compares two messages.
 | 
			
		||||
func equalMessage(mx, my Message) bool {
 | 
			
		||||
	if mx.Descriptor() != my.Descriptor() {
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	nx := 0
 | 
			
		||||
	equal := true
 | 
			
		||||
	mx.Range(func(fd FieldDescriptor, vx Value) bool {
 | 
			
		||||
		nx++
 | 
			
		||||
		vy := my.Get(fd)
 | 
			
		||||
		equal = my.Has(fd) && equalValue(vx, vy)
 | 
			
		||||
		return equal
 | 
			
		||||
	})
 | 
			
		||||
	if !equal {
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
	ny := 0
 | 
			
		||||
	my.Range(func(fd FieldDescriptor, vx Value) bool {
 | 
			
		||||
		ny++
 | 
			
		||||
		return true
 | 
			
		||||
	})
 | 
			
		||||
	if nx != ny {
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return equalUnknown(mx.GetUnknown(), my.GetUnknown())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// equalList compares two lists.
 | 
			
		||||
func equalList(x, y List) bool {
 | 
			
		||||
	if x.Len() != y.Len() {
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
	for i := x.Len() - 1; i >= 0; i-- {
 | 
			
		||||
		if !equalValue(x.Get(i), y.Get(i)) {
 | 
			
		||||
			return false
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return true
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// equalMap compares two maps.
 | 
			
		||||
func equalMap(x, y Map) bool {
 | 
			
		||||
	if x.Len() != y.Len() {
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
	equal := true
 | 
			
		||||
	x.Range(func(k MapKey, vx Value) bool {
 | 
			
		||||
		vy := y.Get(k)
 | 
			
		||||
		equal = y.Has(k) && equalValue(vx, vy)
 | 
			
		||||
		return equal
 | 
			
		||||
	})
 | 
			
		||||
	return equal
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// equalUnknown compares unknown fields by direct comparison on the raw bytes
 | 
			
		||||
// of each individual field number.
 | 
			
		||||
func equalUnknown(x, y RawFields) bool {
 | 
			
		||||
	if len(x) != len(y) {
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
	if bytes.Equal([]byte(x), []byte(y)) {
 | 
			
		||||
		return true
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	mx := make(map[FieldNumber]RawFields)
 | 
			
		||||
	my := make(map[FieldNumber]RawFields)
 | 
			
		||||
	for len(x) > 0 {
 | 
			
		||||
		fnum, _, n := protowire.ConsumeField(x)
 | 
			
		||||
		mx[fnum] = append(mx[fnum], x[:n]...)
 | 
			
		||||
		x = x[n:]
 | 
			
		||||
	}
 | 
			
		||||
	for len(y) > 0 {
 | 
			
		||||
		fnum, _, n := protowire.ConsumeField(y)
 | 
			
		||||
		my[fnum] = append(my[fnum], y[:n]...)
 | 
			
		||||
		y = y[n:]
 | 
			
		||||
	}
 | 
			
		||||
	return reflect.DeepEqual(mx, my)
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										4
									
								
								vendor/google.golang.org/protobuf/reflect/protoreflect/value_union.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/google.golang.org/protobuf/reflect/protoreflect/value_union.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -54,11 +54,11 @@ import (
 | 
			
		||||
//	// Append a 0 to a "repeated int32" field.
 | 
			
		||||
//	// Since the Value returned by Mutable is guaranteed to alias
 | 
			
		||||
//	// the source message, modifying the Value modifies the message.
 | 
			
		||||
//	message.Mutable(fieldDesc).(List).Append(protoreflect.ValueOfInt32(0))
 | 
			
		||||
//	message.Mutable(fieldDesc).List().Append(protoreflect.ValueOfInt32(0))
 | 
			
		||||
//
 | 
			
		||||
//	// Assign [0] to a "repeated int32" field by creating a new Value,
 | 
			
		||||
//	// modifying it, and assigning it.
 | 
			
		||||
//	list := message.NewField(fieldDesc).(List)
 | 
			
		||||
//	list := message.NewField(fieldDesc).List()
 | 
			
		||||
//	list.Append(protoreflect.ValueOfInt32(0))
 | 
			
		||||
//	message.Set(fieldDesc, list)
 | 
			
		||||
//	// ERROR: Since it is not defined whether Set aliases the source,
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								vendor/google.golang.org/protobuf/reflect/protoregistry/registry.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/google.golang.org/protobuf/reflect/protoregistry/registry.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -46,7 +46,7 @@ var conflictPolicy = "panic" // "panic" | "warn" | "ignore"
 | 
			
		||||
// It is a variable so that the behavior is easily overridden in another file.
 | 
			
		||||
var ignoreConflict = func(d protoreflect.Descriptor, err error) bool {
 | 
			
		||||
	const env = "GOLANG_PROTOBUF_REGISTRATION_CONFLICT"
 | 
			
		||||
	const faq = "https://developers.google.com/protocol-buffers/docs/reference/go/faq#namespace-conflict"
 | 
			
		||||
	const faq = "https://protobuf.dev/reference/go/faq#namespace-conflict"
 | 
			
		||||
	policy := conflictPolicy
 | 
			
		||||
	if v := os.Getenv(env); v != "" {
 | 
			
		||||
		policy = v
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user