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>
diff --git a/compiler/protogen/protogen.go b/compiler/protogen/protogen.go
index 1024a84..3c11644 100644
--- a/compiler/protogen/protogen.go
+++ b/compiler/protogen/protogen.go
@@ -355,6 +355,20 @@
// 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 @@
})
}
}
- 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
}