Skip to content

Commit 27277d0

Browse files
committed
Support code generation for lower camel case proto method names.
Motivation: - Ensure compatibility with proto definitions using unconventional lower camel case method names. Changes: - Updated `methodNameGetter` logic to handle method names by converting them to proper camel case format. - Added a test case with a non-conventional `sayHelloLowerCamel` proto method to validate the fix.
1 parent 4318be7 commit 27277d0

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

vertx-grpc-it/src/test/proto/helloworld.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ service Greeter {
9595

9696
// Sends a greeting without the options
9797
rpc SayHelloWithoutOptions (HelloRequest) returns (HelloReply) {}
98+
99+
// Bogus method with a lowerCamelCase name to exercise code generation for
100+
// non-conventional proto method names. Not invoked by tests.
101+
rpc sayHelloLowerCamel (HelloRequest) returns (HelloReply) {}
98102
}
99103

100104
// The request message containing the user's name.

vertx-grpc-protoc-plugin2/src/main/java/io/vertx/grpc/plugin/generation/context/MethodTemplateContext.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.vertx.grpc.plugin.generation.context;
22

3+
import io.vertx.codegen.format.CamelCase;
4+
import io.vertx.codegen.format.LowerCamelCase;
35
import io.vertx.grpc.plugin.descriptors.MethodDescriptor;
46

57
public class MethodTemplateContext {
@@ -49,7 +51,7 @@ public String methodNameUpperUnderscore() {
4951
}
5052

5153
public String methodNameGetter() {
52-
return NameUtils.formatMethodName("Get" + methodName + "Method");
54+
return NameUtils.formatMethodName("Get" + CamelCase.INSTANCE.format(LowerCamelCase.INSTANCE.parse(methodName)) + "Method");
5355
}
5456

5557
private static String buildMethodHeader(MethodDescriptor method) {

0 commit comments

Comments
 (0)