mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2024-12-26 21:24:22 +00:00
compiler/protogen: always report editions support level of the plugin
Change-Id: I11bb6c37ac9b15e2dfb11c38c4a68900dd63d327 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/597055 Auto-Submit: Lasse Folger <lassefolger@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Chressie Himpel <chressie@google.com>
This commit is contained in:
parent
eea33cd93e
commit
df3bd63b9c
@ -355,6 +355,20 @@ func (gen *Plugin) Error(err error) {
|
||||
// Response returns the generator output.
|
||||
func (gen *Plugin) Response() *pluginpb.CodeGeneratorResponse {
|
||||
resp := &pluginpb.CodeGeneratorResponse{}
|
||||
// Always report the support for editions. Otherwise protoc might obfuscate
|
||||
// the error by saying editions are not supported by the plugin.
|
||||
// It is arguable if protoc should handle this but it is possible that the
|
||||
// error only exists because the plugin does not support editions and thus
|
||||
// it is not unreasonable for protoc to suspect it is the lack of editions
|
||||
// support that led to this error.
|
||||
if gen.SupportedFeatures > 0 {
|
||||
resp.SupportedFeatures = proto.Uint64(gen.SupportedFeatures)
|
||||
}
|
||||
if gen.SupportedEditionsMinimum != descriptorpb.Edition_EDITION_UNKNOWN && gen.SupportedEditionsMaximum != descriptorpb.Edition_EDITION_UNKNOWN {
|
||||
resp.MinimumEdition = proto.Int32(int32(gen.SupportedEditionsMinimum))
|
||||
resp.MaximumEdition = proto.Int32(int32(gen.SupportedEditionsMaximum))
|
||||
}
|
||||
|
||||
if gen.err != nil {
|
||||
resp.Error = proto.String(gen.err.Error())
|
||||
return resp
|
||||
@ -396,13 +410,6 @@ func (gen *Plugin) Response() *pluginpb.CodeGeneratorResponse {
|
||||
})
|
||||
}
|
||||
}
|
||||
if gen.SupportedFeatures > 0 {
|
||||
resp.SupportedFeatures = proto.Uint64(gen.SupportedFeatures)
|
||||
}
|
||||
if gen.SupportedEditionsMinimum != descriptorpb.Edition_EDITION_UNKNOWN && gen.SupportedEditionsMaximum != descriptorpb.Edition_EDITION_UNKNOWN {
|
||||
resp.MinimumEdition = proto.Int32(int32(gen.SupportedEditionsMinimum))
|
||||
resp.MaximumEdition = proto.Int32(int32(gen.SupportedEditionsMaximum))
|
||||
}
|
||||
return resp
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user