Skip to content

Commit

Permalink
Merge pull request #3170 from square/bquenaudon.2024-11-08.kotlin2
Browse files Browse the repository at this point in the history
Bump to KotlinPoet2 and regenerate it all
  • Loading branch information
oldergod authored Nov 8, 2024
2 parents 0297ce6 + 839879e commit 6fe1669
Show file tree
Hide file tree
Showing 133 changed files with 988 additions and 1,564 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jmh = "1.37"
jsr305 = "3.0.2"
junit = "4.13.2"
kotlin = "2.0.21"
kotlinpoet = "1.18.1"
kotlinpoet = "2.0.0"
ktlint = "0.48.2"
moshi = "1.15.1"
okhttp = "5.0.0-alpha.14"
Expand Down
147 changes: 69 additions & 78 deletions wire-golden-files/src/main/kotlin/squareup/wire/alltypes/AllTypes.kt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ public class BoxedOneOfs(
return result.joinToString(prefix = "BoxedOneOfs{", separator = ", ", postfix = "}")
}

public fun copy(value_: OneOf<Value<*>, *>? = this.value_, unknownFields: ByteString =
this.unknownFields): BoxedOneOfs = BoxedOneOfs(value_, unknownFields)
public fun copy(value_: OneOf<Value<*>, *>? = this.value_, unknownFields: ByteString = this.unknownFields): BoxedOneOfs = BoxedOneOfs(value_, unknownFields)

public class Builder : Message.Builder<BoxedOneOfs, Builder>() {
@JvmField
Expand Down Expand Up @@ -144,18 +143,18 @@ public class BoxedOneOfs(
)
}

public val VALUE_FIRST_VALUE: Value<String> = Value<String>(tag = 1, adapter =
ProtoAdapter.STRING, declaredName = "first_value")
public val VALUE_FIRST_VALUE: Value<String> =
Value<String>(tag = 1, adapter = ProtoAdapter.STRING, declaredName = "first_value")

public val VALUE_SECOND_VALUE: Value<String> = Value<String>(tag = 2, adapter =
ProtoAdapter.STRING, declaredName = "second_value")
public val VALUE_SECOND_VALUE: Value<String> =
Value<String>(tag = 2, adapter = ProtoAdapter.STRING, declaredName = "second_value")

public val VALUE_VALUE: Value<String> = Value<String>(tag = 3, adapter = ProtoAdapter.STRING,
declaredName = "value")
public val VALUE_VALUE: Value<String> =
Value<String>(tag = 3, adapter = ProtoAdapter.STRING, declaredName = "value")

@JvmStatic
public val VALUE__KEYS: Set<Value<*>> = setOf(VALUE_FIRST_VALUE, VALUE_SECOND_VALUE,
VALUE_VALUE)
public val VALUE__KEYS: Set<Value<*>> =
setOf(VALUE_FIRST_VALUE, VALUE_SECOND_VALUE, VALUE_VALUE)

private const val serialVersionUID: Long = 0L

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,7 @@ public class SomeMessage private constructor(
private const val serialVersionUID: Long = 0L

@JvmSynthetic
public inline fun build(body: Builder.() -> Unit): NestedMessage =
Builder().apply(body).build()
public inline fun build(body: Builder.() -> Unit): NestedMessage = Builder().apply(body).build()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ public class ParameterValue(
message = "Shouldn't be used in Kotlin",
level = DeprecationLevel.HIDDEN,
)
override fun newBuilder(): Nothing = throw
AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")
override fun newBuilder(): Nothing = throw AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")

override fun equals(other: Any?): Boolean {
if (other === this) return true
Expand All @@ -75,8 +74,7 @@ public class ParameterValue(
return result.joinToString(prefix = "ParameterValue{", separator = ", ", postfix = "}")
}

public fun copy(data_: List<Float> = this.data_, unknownFields: ByteString = this.unknownFields):
ParameterValue = ParameterValue(data_, unknownFields)
public fun copy(data_: List<Float> = this.data_, unknownFields: ByteString = this.unknownFields): ParameterValue = ParameterValue(data_, unknownFields)

public companion object {
@JvmField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ public class ParameterValueWithArray(
message = "Shouldn't be used in Kotlin",
level = DeprecationLevel.HIDDEN,
)
override fun newBuilder(): Nothing = throw
AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")
override fun newBuilder(): Nothing = throw AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")

override fun equals(other: Any?): Boolean {
if (other === this) return true
Expand All @@ -74,13 +73,12 @@ public class ParameterValueWithArray(
return result.joinToString(prefix = "ParameterValueWithArray{", separator = ", ", postfix = "}")
}

public fun copy(data_: FloatArray = this.data_, unknownFields: ByteString = this.unknownFields):
ParameterValueWithArray = ParameterValueWithArray(data_, unknownFields)
public fun copy(data_: FloatArray = this.data_, unknownFields: ByteString = this.unknownFields): ParameterValueWithArray = ParameterValueWithArray(data_, unknownFields)

public companion object {
@JvmField
public val ADAPTER: ProtoAdapter<ParameterValueWithArray> = object :
ProtoAdapter<ParameterValueWithArray>(
public val ADAPTER: ProtoAdapter<ParameterValueWithArray> =
object : ProtoAdapter<ParameterValueWithArray>(
FieldEncoding.LENGTH_DELIMITED,
ParameterValueWithArray::class,
"type.googleapis.com/squareup.wire.repeateddata.ParameterValueWithArray",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public class Easter private constructor(
schemaIndex = 2,
)
@JvmField
public val easter_animals: List<EasterAnimal> = immutableCopyOf("easter_animals",
builder.easter_animals)
public val easter_animals: List<EasterAnimal> =
immutableCopyOf("easter_animals", builder.easter_animals)

override fun newBuilder(): Builder {
val builder = Builder()
Expand Down Expand Up @@ -99,8 +99,7 @@ public class Easter private constructor(

override fun toString(): String {
val result = mutableListOf<String>()
if (optional_easter_animal != null) result +=
"""optional_easter_animal=$optional_easter_animal"""
if (optional_easter_animal != null) result += """optional_easter_animal=$optional_easter_animal"""
result += """identity_easter_animal=$identity_easter_animal"""
if (easter_animals.isNotEmpty()) result += """easter_animals=$easter_animals"""
return result.joinToString(prefix = "Easter{", separator = ", ", postfix = "}")
Expand Down Expand Up @@ -151,8 +150,7 @@ public class Easter private constructor(
override fun encodedSize(`value`: Easter): Int {
var size = value.unknownFields.size
size += EasterAnimal.ADAPTER.encodedSizeWithTag(2, value.optional_easter_animal)
if (value.identity_easter_animal !=
squareup.wire.unrecognized_constant.EasterAnimal.EASTER_ANIMAL_DEFAULT) {
if (value.identity_easter_animal != squareup.wire.unrecognized_constant.EasterAnimal.EASTER_ANIMAL_DEFAULT) {
size += EasterAnimal.ADAPTER.encodedSizeWithTag(3, value.identity_easter_animal)
}
size += EasterAnimal.ADAPTER.asRepeated().encodedSizeWithTag(4, value.easter_animals)
Expand All @@ -161,8 +159,7 @@ public class Easter private constructor(

override fun encode(writer: ProtoWriter, `value`: Easter) {
EasterAnimal.ADAPTER.encodeWithTag(writer, 2, value.optional_easter_animal)
if (value.identity_easter_animal !=
squareup.wire.unrecognized_constant.EasterAnimal.EASTER_ANIMAL_DEFAULT) {
if (value.identity_easter_animal != squareup.wire.unrecognized_constant.EasterAnimal.EASTER_ANIMAL_DEFAULT) {
EasterAnimal.ADAPTER.encodeWithTag(writer, 3, value.identity_easter_animal)
}
EasterAnimal.ADAPTER.asRepeated().encodeWithTag(writer, 4, value.easter_animals)
Expand All @@ -172,8 +169,7 @@ public class Easter private constructor(
override fun encode(writer: ReverseProtoWriter, `value`: Easter) {
writer.writeBytes(value.unknownFields)
EasterAnimal.ADAPTER.asRepeated().encodeWithTag(writer, 4, value.easter_animals)
if (value.identity_easter_animal !=
squareup.wire.unrecognized_constant.EasterAnimal.EASTER_ANIMAL_DEFAULT) {
if (value.identity_easter_animal != squareup.wire.unrecognized_constant.EasterAnimal.EASTER_ANIMAL_DEFAULT) {
EasterAnimal.ADAPTER.encodeWithTag(writer, 3, value.identity_easter_animal)
}
EasterAnimal.ADAPTER.encodeWithTag(writer, 2, value.optional_easter_animal)
Expand Down
3 changes: 1 addition & 2 deletions wire-grpc-tests/src/test/proto-grpc/routeguide/Feature.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ public class Feature(
message = "Shouldn't be used in Kotlin",
level = DeprecationLevel.HIDDEN,
)
override fun newBuilder(): Nothing = throw
AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")
override fun newBuilder(): Nothing = throw AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")

override fun equals(other: Any?): Boolean {
if (other === this) return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ public class FeatureDatabase(
message = "Shouldn't be used in Kotlin",
level = DeprecationLevel.HIDDEN,
)
override fun newBuilder(): Nothing = throw
AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")
override fun newBuilder(): Nothing = throw AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")

override fun equals(other: Any?): Boolean {
if (other === this) return true
Expand All @@ -77,8 +76,7 @@ public class FeatureDatabase(
return result.joinToString(prefix = "FeatureDatabase{", separator = ", ", postfix = "}")
}

public fun copy(feature: List<Feature> = this.feature, unknownFields: ByteString =
this.unknownFields): FeatureDatabase = FeatureDatabase(feature, unknownFields)
public fun copy(feature: List<Feature> = this.feature, unknownFields: ByteString = this.unknownFields): FeatureDatabase = FeatureDatabase(feature, unknownFields)

public companion object {
@JvmField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ public class GrpcRouteGuideClient(
* repeated field), as the rectangle may cover a large area and contain a
* huge number of features.
*/
override fun ListFeatures(): GrpcStreamingCall<Rectangle, Feature> =
client.newStreamingCall(GrpcMethod(
override fun ListFeatures(): GrpcStreamingCall<Rectangle, Feature> = client.newStreamingCall(GrpcMethod(
path = "/routeguide.RouteGuide/ListFeatures",
requestAdapter = Rectangle.ADAPTER,
responseAdapter = Feature.ADAPTER
Expand All @@ -54,8 +53,7 @@ public class GrpcRouteGuideClient(
* Accepts a stream of Points on a route being traversed, returning a
* RouteSummary when traversal is completed.
*/
override fun RecordRoute(): GrpcStreamingCall<Point, RouteSummary> =
client.newStreamingCall(GrpcMethod(
override fun RecordRoute(): GrpcStreamingCall<Point, RouteSummary> = client.newStreamingCall(GrpcMethod(
path = "/routeguide.RouteGuide/RecordRoute",
requestAdapter = Point.ADAPTER,
responseAdapter = RouteSummary.ADAPTER
Expand All @@ -67,8 +65,7 @@ public class GrpcRouteGuideClient(
* Accepts a stream of RouteNotes sent while a route is being traversed,
* while receiving other RouteNotes (e.g. from other users).
*/
override fun RouteChat(): GrpcStreamingCall<RouteNote, RouteNote> =
client.newStreamingCall(GrpcMethod(
override fun RouteChat(): GrpcStreamingCall<RouteNote, RouteNote> = client.newStreamingCall(GrpcMethod(
path = "/routeguide.RouteGuide/RouteChat",
requestAdapter = RouteNote.ADAPTER,
responseAdapter = RouteNote.ADAPTER
Expand Down
3 changes: 1 addition & 2 deletions wire-grpc-tests/src/test/proto-grpc/routeguide/Point.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ public class Point(
message = "Shouldn't be used in Kotlin",
level = DeprecationLevel.HIDDEN,
)
override fun newBuilder(): Nothing = throw
AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")
override fun newBuilder(): Nothing = throw AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")

override fun equals(other: Any?): Boolean {
if (other === this) return true
Expand Down
3 changes: 1 addition & 2 deletions wire-grpc-tests/src/test/proto-grpc/routeguide/Rectangle.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public class Rectangle(
message = "Shouldn't be used in Kotlin",
level = DeprecationLevel.HIDDEN,
)
override fun newBuilder(): Nothing = throw
AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")
override fun newBuilder(): Nothing = throw AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")

override fun equals(other: Any?): Boolean {
if (other === this) return true
Expand Down
3 changes: 1 addition & 2 deletions wire-grpc-tests/src/test/proto-grpc/routeguide/RouteNote.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public class RouteNote(
message = "Shouldn't be used in Kotlin",
level = DeprecationLevel.HIDDEN,
)
override fun newBuilder(): Nothing = throw
AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")
override fun newBuilder(): Nothing = throw AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")

override fun equals(other: Any?): Boolean {
if (other === this) return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ public class RouteSummary(
message = "Shouldn't be used in Kotlin",
level = DeprecationLevel.HIDDEN,
)
override fun newBuilder(): Nothing = throw
AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")
override fun newBuilder(): Nothing = throw AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")

override fun equals(other: Any?): Boolean {
if (other === this) return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ public class Dinosaur(
message = "Shouldn't be used in Kotlin",
level = DeprecationLevel.HIDDEN,
)
override fun newBuilder(): Nothing = throw
AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")
override fun newBuilder(): Nothing = throw AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")

override fun equals(other: Any?): Boolean {
if (other === this) return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ public class Getters(
message = "Shouldn't be used in Kotlin",
level = DeprecationLevel.HIDDEN,
)
override fun newBuilder(): Nothing = throw
AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")
override fun newBuilder(): Nothing = throw AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")

override fun equals(other: Any?): Boolean {
if (other === this) return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ public class Person(
message = "Shouldn't be used in Kotlin",
level = DeprecationLevel.HIDDEN,
)
override fun newBuilder(): Nothing = throw
AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")
override fun newBuilder(): Nothing = throw AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")

override fun equals(other: Any?): Boolean {
if (other === this) return true
Expand Down Expand Up @@ -171,8 +170,7 @@ public class Person(
area_numbers: Map<Int, String> = this.area_numbers,
is_canadian: Boolean? = this.is_canadian,
unknownFields: ByteString = this.unknownFields,
): Person = Person(name, id, email, phone, favorite_numbers, area_numbers, is_canadian,
unknownFields)
): Person = Person(name, id, email, phone, favorite_numbers, area_numbers, is_canadian, unknownFields)

public companion object {
@JvmField
Expand All @@ -184,8 +182,8 @@ public class Person(
null,
"person_kotlin.proto"
) {
private val area_numbersAdapter: ProtoAdapter<Map<Int, String>> by lazy {
ProtoAdapter.newMapAdapter(ProtoAdapter.INT32, ProtoAdapter.STRING) }
private val area_numbersAdapter: ProtoAdapter<Map<Int, String>> by
lazy { ProtoAdapter.newMapAdapter(ProtoAdapter.INT32, ProtoAdapter.STRING) }

override fun encodedSize(`value`: Person): Int {
var size = value.unknownFields.size
Expand Down Expand Up @@ -331,8 +329,7 @@ public class Person(
message = "Shouldn't be used in Kotlin",
level = DeprecationLevel.HIDDEN,
)
override fun newBuilder(): Nothing = throw
AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")
override fun newBuilder(): Nothing = throw AssertionError("Builders are deprecated and only available in a javaInterop build; see https://square.github.io/wire/wire_compiler/#kotlin")

override fun equals(other: Any?): Boolean {
if (other === this) return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ public class KeywordKotlin(
null,
"keyword_kotlin.proto"
) {
private val funAdapter: ProtoAdapter<Map<String, String>> by lazy {
ProtoAdapter.newMapAdapter(ProtoAdapter.STRING, ProtoAdapter.STRING) }
private val funAdapter: ProtoAdapter<Map<String, String>> by
lazy { ProtoAdapter.newMapAdapter(ProtoAdapter.STRING, ProtoAdapter.STRING) }

override fun encodedSize(`value`: KeywordKotlin): Int {
var size = value.unknownFields.size
Expand Down Expand Up @@ -306,8 +306,7 @@ public class KeywordKotlin(
PROTO_2,
KeywordKotlinEnum.object_
) {
override fun fromValue(`value`: Int): KeywordKotlinEnum? =
KeywordKotlinEnum.fromValue(`value`)
override fun fromValue(`value`: Int): KeywordKotlinEnum? = KeywordKotlinEnum.fromValue(`value`)
}

@JvmStatic
Expand Down
Loading

0 comments on commit 6fe1669

Please sign in to comment.