Skip to content

Commit

Permalink
compiler/protogen: always report editions support level of the plugin
Browse files Browse the repository at this point in the history
Change-Id: I11bb6c37ac9b15e2dfb11c38c4a68900dd63d327
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/597055
Auto-Submit: Lasse Folger <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Chressie Himpel <[email protected]>
  • Loading branch information
lfolger authored and gopherbot committed Jul 8, 2024
1 parent eea33cd commit df3bd63
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions compiler/protogen/protogen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit df3bd63

Please sign in to comment.