x/ref: Disallow uppercase acronyms in VDL identifiers.
The purpose of this change is to ensure code in each generated
language is idiomatic and looks reasonable. The problem with
uppercase acronyms is they either look bad or are non-reversible,
when converted to camelCase or CONST_CASE.
E.g. EOF is converted to eOF, which looks bad. MyTTL is
converted to MY_TTL, which is non-reversible.
Const identifiers are currently special-cased to avoid this rule.
In the future we may choose to change to the same rule for const
identifiers; this is less important since const identifiers are
never sent over the wire.
MultiPart: 2/3
Change-Id: I1673c92763bb09257a285c381a256ec2d773ee3c
diff --git a/lib/vdl/codegen/java/file_client_stub.go b/lib/vdl/codegen/java/file_client_stub.go
index b820015..55ac9e1 100644
--- a/lib/vdl/codegen/java/file_client_stub.go
+++ b/lib/vdl/codegen/java/file_client_stub.go
@@ -194,7 +194,7 @@
func processClientStubMethod(iface *compile.Interface, method *compile.Method, env *compile.Env) clientStubMethod {
outArgs := make([]clientStubMethodOutArg, len(method.OutArgs))
for i := 0; i < len(method.OutArgs); i++ {
- outArgs[i].FieldName = vdlutil.ToCamelCase(method.OutArgs[i].Name)
+ outArgs[i].FieldName = vdlutil.FirstRuneToLower(method.OutArgs[i].Name)
outArgs[i].Type = javaType(method.OutArgs[i].Type, true, env)
}
return clientStubMethod{
@@ -206,14 +206,14 @@
DeclaredObjectRetType: clientInterfaceNonStreamingOutArg(iface, method, true, env),
IsVoid: len(method.OutArgs) < 1,
MultipleReturn: len(method.OutArgs) > 1,
- Name: vdlutil.ToCamelCase(method.Name),
+ Name: vdlutil.FirstRuneToLower(method.Name),
NotStreaming: !isStreamingMethod(method),
OutArgs: outArgs,
RecvType: javaType(method.OutStream, true, env),
RetType: clientInterfaceOutArg(iface, method, false, env),
Returns: len(method.OutArgs) >= 1 || isStreamingMethod(method),
SendType: javaType(method.InStream, true, env),
- ServiceName: toUpperCamelCase(iface.Name),
+ ServiceName: vdlutil.FirstRuneToUpper(iface.Name),
}
}
@@ -222,8 +222,8 @@
AccessModifier: accessModifierForName(embedMethod.Name),
CallingArgsLeadingComma: javaCallingArgStr(embedMethod.InArgs, true),
DeclarationArgs: javaDeclarationArgStr(embedMethod.InArgs, env, true),
- LocalStubVarName: vdlutil.ToCamelCase(iface.Name) + "ClientStub",
- Name: vdlutil.ToCamelCase(embedMethod.Name),
+ LocalStubVarName: vdlutil.FirstRuneToLower(iface.Name) + "ClientStub",
+ Name: vdlutil.FirstRuneToLower(embedMethod.Name),
RetType: clientInterfaceOutArg(iface, embedMethod, false, env),
Returns: len(embedMethod.OutArgs) >= 1 || isStreamingMethod(embedMethod),
}
@@ -234,8 +234,8 @@
embeds := []clientStubEmbed{}
for _, embed := range allEmbeddedIfaces(iface) {
embeds = append(embeds, clientStubEmbed{
- LocalStubVarName: vdlutil.ToCamelCase(embed.Name) + "ClientStub",
- StubClassName: javaPath(javaGenPkgPath(path.Join(embed.File.Package.GenPath, toUpperCamelCase(embed.Name)+"ClientStub"))),
+ LocalStubVarName: vdlutil.FirstRuneToLower(embed.Name) + "ClientStub",
+ StubClassName: javaPath(javaGenPkgPath(path.Join(embed.File.Package.GenPath, vdlutil.FirstRuneToUpper(embed.Name)+"ClientStub"))),
})
}
embedMethods := []clientStubEmbedMethod{}
@@ -246,7 +246,7 @@
for i, method := range iface.Methods {
methods[i] = processClientStubMethod(iface, method, env)
}
- javaServiceName := toUpperCamelCase(iface.Name)
+ javaServiceName := vdlutil.FirstRuneToUpper(iface.Name)
data := struct {
AccessModifier string
EmbedMethods []clientStubEmbedMethod