Populate the pb::java feature extension to gprc proto plugin (#11885)

Populate the pb::java feature extension to the protoc plugins that require Protobuf Java feature resolution for the  edition.
This commit is contained in:
Dennis Shao 2025-03-17 09:16:28 -04:00 committed by GitHub
parent fca1d3cf43
commit b69bd64ce7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 0 deletions

View File

@ -23,6 +23,9 @@
#include "java_generator.h"
#include <google/protobuf/compiler/code_generator.h>
#if GOOGLE_PROTOBUF_VERSION >= 5027000
#include <google/protobuf/compiler/java/java_features.pb.h>
#endif
#include <google/protobuf/compiler/plugin.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/io/zero_copy_stream.h>
@ -57,6 +60,10 @@ class JavaGrpcGenerator : public protobuf::compiler::CodeGenerator {
protobuf::Edition GetMaximumEdition() const override {
return protobuf::Edition::EDITION_2023;
}
std::vector<const protobuf::FieldDescriptor*> GetFeatureExtensions()
const override {
return {GetExtensionReflection(pb::java)};
}
#else
uint64_t GetSupportedFeatures() const override {
return Feature::FEATURE_PROTO3_OPTIONAL;