Skip to content

Commit

Permalink
fix potential compile failure for long protobuf message name (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
mscheong01 committed Mar 2, 2024
1 parent 359c82c commit 3e49bd8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ class FromJsonFunctionGenerator : FunSpecGenerator<Descriptor> {
)
.receiver(generatedTypeCompanion)
.returns(generatedType)
functionBuilder.addCode("return %L.newBuilder().apply { JsonFormat.parser().ignoringUnknownFields().merge(json, this@apply) }.build().toDataClass();\n", protoType)
functionBuilder.addCode("return %L.newBuilder()\n", protoType)
functionBuilder.addCode(" .apply {\n")
functionBuilder.addCode(" JsonFormat.parser().ignoringUnknownFields().merge(json, this@apply)\n")
functionBuilder.addCode(" }.build().toDataClass();\n")

imports.add(Import("com.google.protobuf.util", listOf("JsonFormat")))
return FunSpecsWithImports(
Expand Down
11 changes: 11 additions & 0 deletions generator/src/test/proto/very_long_message.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax = "proto3";

option java_multiple_files = true;
option java_package = "com.example.application.system.types";
option java_outer_classname = "VeryLongMessageNameProto";

package com.example.application.system.types;

message VeryVeryLongTestProtocolBuffersMessageName {
repeated string type = 1;
}

0 comments on commit 3e49bd8

Please sign in to comment.