Skip to content

Commit 3e49bd8

Browse files
authored
fix potential compile failure for long protobuf message name (#27)
1 parent 359c82c commit 3e49bd8

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

generator/src/main/kotlin/io/github/mscheong01/krotodc/specgenerators/function/FromJsonFunctionGenerator.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ class FromJsonFunctionGenerator : FunSpecGenerator<Descriptor> {
4242
)
4343
.receiver(generatedTypeCompanion)
4444
.returns(generatedType)
45-
functionBuilder.addCode("return %L.newBuilder().apply { JsonFormat.parser().ignoringUnknownFields().merge(json, this@apply) }.build().toDataClass();\n", protoType)
45+
functionBuilder.addCode("return %L.newBuilder()\n", protoType)
46+
functionBuilder.addCode(" .apply {\n")
47+
functionBuilder.addCode(" JsonFormat.parser().ignoringUnknownFields().merge(json, this@apply)\n")
48+
functionBuilder.addCode(" }.build().toDataClass();\n")
4649

4750
imports.add(Import("com.google.protobuf.util", listOf("JsonFormat")))
4851
return FunSpecsWithImports(
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
syntax = "proto3";
2+
3+
option java_multiple_files = true;
4+
option java_package = "com.example.application.system.types";
5+
option java_outer_classname = "VeryLongMessageNameProto";
6+
7+
package com.example.application.system.types;
8+
9+
message VeryVeryLongTestProtocolBuffersMessageName {
10+
repeated string type = 1;
11+
}

0 commit comments

Comments
 (0)