-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Final updates to runtime and codegen fixes #352
Changes from 3 commits
f4d07c3
6dbb5df
a92ca56
f20d92c
0c93cb9
c4fd49a
02e2b2c
c0ef0a8
4afdad2
50142b6
bd2aa21
efa76b0
431d5a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 2020 Toast, Inc. | ||
* Copyright (c) 2022 Toast, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
|
@@ -13,6 +13,4 @@ | |
* limitations under the License. | ||
*/ | ||
|
||
subprojects { | ||
group = "${rootProject.group}.thirdparty" | ||
} | ||
group = "com.toasttab.protokt.thirdparty" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was getting clobbered by the common-conventions plugin - we've been publishing to the wrong group since that change went in. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,15 +27,24 @@ import protokt.v1.codegen.generate.Nullability.nonNullPropName | |
import protokt.v1.codegen.util.Message | ||
import protokt.v1.codegen.util.StandardField | ||
import kotlin.reflect.KClass | ||
import kotlin.reflect.KProperty | ||
|
||
internal object Implements { | ||
class OverriddenProperty( | ||
val property: KProperty<*> | ||
) | ||
|
||
fun StandardField.overrides( | ||
ctx: Context, | ||
msg: Message | ||
) = | ||
msg.superInterface(ctx) | ||
?.let { fieldName in ctx.info.context.classLookup.properties(it.canonicalName).map { p -> p.name } } | ||
?: false | ||
?.let { | ||
ctx.info.context.classLookup | ||
.properties(it.canonicalName) | ||
.find { p -> p.name == fieldName } | ||
?.let(::OverriddenProperty) | ||
} | ||
|
||
fun TypeSpec.Builder.handleSuperInterface(implements: ClassName?, v: OneofGeneratorInfo? = null) = | ||
apply { | ||
|
@@ -61,7 +70,7 @@ internal object Implements { | |
} | ||
|
||
private fun TypeSpec.Builder.delegateProperties(msg: Message, ctx: Context, canonicalName: String, fieldName: String) { | ||
val fieldsByName = msg.fields.filterIsInstance<StandardField>().associateBy { it.fieldName } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't exclude overrides that are oneofs. |
||
val fieldsByName = msg.fields.associateBy { it.fieldName } | ||
|
||
val interfaceFields = | ||
ctx.info.context.classLookup | ||
|
@@ -77,7 +86,7 @@ internal object Implements { | |
field.name, | ||
(field.returnType.classifier as KClass<*>).asTypeName() | ||
.let { | ||
if (assumeNotNull) { | ||
if (assumeNotNull && !field.returnType.isMarkedNullable) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't delegate a field and mark it as non-nullable if the delegated field is nullable in the interface. |
||
it | ||
} else { | ||
it.copy(nullable = true) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,6 @@ private fun generateFdpObjectNames(files: List<FileDescriptorProto>): Map<String | |
Pair( | ||
fdp.name, | ||
fdp.fileOptions.protokt.fileDescriptorObjectName.takeIf { it.isNotEmpty() } | ||
?: fdp.fileOptions.default.javaOuterClassname.takeIf { it.isNotEmpty() } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ignore all Java options. |
||
?: (fdp.name.substringBefore(".proto").substringAfterLast('/') + "_file_descriptor") | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the default value.