salesforce / grpc-java-contrib

Useful extensions for the grpc-java library
BSD 3-Clause "New" or "Revised" License
219 stars 34 forks source link

Expose getJavaOuterClassname in JProtoc #169

Closed Fadelis closed 1 year ago

Fadelis commented 2 years ago

When extending base generated java classes you need to provide the file path to the actual .java file and determining it involves a bit of logic that you've already implemented. So to make it easier to develop protoc extension plugins I'd suggest to expose this method: https://github.com/salesforce/grpc-java-contrib/blob/79aeea46a61b9f3d724a172ab29374931c02fa7c/jprotoc/jprotoc/src/main/java/com/salesforce/jprotoc/ProtoTypeMap.java#L105

Current workaround I've implemented is to extract the filename from the JavaType provided in this map: https://github.com/Fadelis/protoc-gen-java-optional/blob/055440fe6ca14dfeb8ba96413880dd3f45e82fd8/protoc-gen-java-optional/src/main/java/org/grpcmock/protoc/plugin/OptionalGenerator.java#L210-L215