supported_features.go 788 B

123456789101112131415161718192021222324
  1. package codegenerator
  2. import (
  3. "google.golang.org/protobuf/compiler/protogen"
  4. "google.golang.org/protobuf/types/pluginpb"
  5. )
  6. func supportedCodeGeneratorFeatures() uint64 {
  7. // Enable support for optional keyword in proto3.
  8. return uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL)
  9. }
  10. // SetSupportedFeaturesOnPluginGen sets supported proto3 features
  11. // on protogen.Plugin.
  12. func SetSupportedFeaturesOnPluginGen(gen *protogen.Plugin) {
  13. gen.SupportedFeatures = supportedCodeGeneratorFeatures()
  14. }
  15. // SetSupportedFeaturesOnCodeGeneratorResponse sets supported proto3 features
  16. // on pluginpb.CodeGeneratorResponse.
  17. func SetSupportedFeaturesOnCodeGeneratorResponse(resp *pluginpb.CodeGeneratorResponse) {
  18. sf := supportedCodeGeneratorFeatures()
  19. resp.SupportedFeatures = &sf
  20. }