-
Notifications
You must be signed in to change notification settings - Fork 55
Create new codegen module and refactor annotation processor to use it #1382
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
Conversation
|
A new generated diff is ready to view.
|
|
A new generated diff is ready to view.
|
hll/codegen/src/main/kotlin/aws/sdk/kotlin/hll/codegen/core/CodeGenerator.kt
Show resolved
Hide resolved
...rocessor/jvm/src/aws/sdk/kotlin/hll/dynamodbmapper/processor/rendering/AnnotationRenderer.kt
Outdated
Show resolved
Hide resolved
...rocessor/jvm/src/aws/sdk/kotlin/hll/dynamodbmapper/processor/rendering/AnnotationRenderer.kt
Outdated
Show resolved
Hide resolved
|
A new generated diff is ready to view.
|
|
A new generated diff is ready to view.
|
ianbotsf
left a comment
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.
Looks like a great start! In general I like the stuff you pulled out into a common module but I think we should be more zealous about using #T and type references rather than #L and names that we assume are in scope.
hll/codegen/src/main/kotlin/aws/sdk/kotlin/hll/codegen/core/CodeGenerator.kt
Show resolved
Hide resolved
hll/codegen/src/main/kotlin/aws/sdk/kotlin/hll/codegen/core/ImportDirectives.kt
Outdated
Show resolved
Hide resolved
hll/codegen/src/main/kotlin/aws/sdk/kotlin/hll/codegen/model/Type.kt
Outdated
Show resolved
Hide resolved
...rocessor/jvm/src/aws/sdk/kotlin/hll/dynamodbmapper/processor/rendering/AnnotationRenderer.kt
Outdated
Show resolved
Hide resolved
...rocessor/jvm/src/aws/sdk/kotlin/hll/dynamodbmapper/processor/rendering/AnnotationRenderer.kt
Outdated
Show resolved
Hide resolved
...-annotation-processor/jvm/src/aws/sdk/kotlin/hll/dynamodbmapper/processor/MapperProcessor.kt
Outdated
Show resolved
Hide resolved
...processor/jvm/src/aws/sdk/kotlin/hll/dynamodbmapper/processor/rendering/HighLevelRenderer.kt
Outdated
Show resolved
Hide resolved
hll/codegen/src/main/kotlin/aws/sdk/kotlin/hll/codegen/model/Type.kt
Outdated
Show resolved
Hide resolved
| val annotated = resolver.getSymbolsWithAnnotation(annotationName) | ||
| val invalid = annotated.filterNot { it.validate() }.toList() | ||
| env.logger.info("Found invalid classes $invalid") | ||
| logger.info("Found invalid classes $invalid") |
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.
question: will we always have invalid classes?
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.
I'm not sure, this validation is something done by KSP
| val ddbName = ksProperty.getAnnotationsByType(DynamoDbAttribute::class).singleOrNull()?.name ?: name | ||
| Property(name, ddbName, typeName, isPk) | ||
| } | ||
| return invalid |
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.
question: I think I'm missing some context here, why are we returning invalid?
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.
The behavior of returning unprocessed symbols is defined by KSP
|
A new generated diff is ready to view.
|
ianbotsf
left a comment
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.
Nice improvements! No blocking concerns left for me so leaving an approval conditional on addressing the remaining nits and questions. Style and suggestion comments optional.
hll/codegen/src/main/kotlin/aws/sdk/kotlin/hll/codegen/core/TemplateProcessor.kt
Show resolved
Hide resolved
hll/codegen/src/main/kotlin/aws/sdk/kotlin/hll/codegen/model/Types.kt
Outdated
Show resolved
Hide resolved
hll/codegen/src/main/kotlin/aws/sdk/kotlin/hll/codegen/rendering/BuilderRenderer.kt
Outdated
Show resolved
Hide resolved
hll/codegen/src/main/kotlin/aws/sdk/kotlin/hll/codegen/rendering/BuilderRenderer.kt
Outdated
Show resolved
Hide resolved
| import com.google.devtools.ksp.symbol.* | ||
|
|
||
| /** | ||
| * A DSL-style builder renderer. | ||
| * @param renderer The base renderer in which the builder will be written | ||
| * @param classDeclaration The [KSClassDeclaration] for which a builder will be generated | ||
| */ | ||
| class BuilderRenderer( | ||
| private val renderer: RendererBase, | ||
| private val classDeclaration: KSClassDeclaration, | ||
| ) { |
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.
Comment: A lot of KSP types have bled into this renderer. I can't definitively say that's wrong but I wonder if coupling too tightly in deep places will be an issue at some point. 🤔
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.
I agree, let me try to stop the bleeding by just passing a TypeRef
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.
I think I've got a way cleaner signature now:
/**
* A DSL-style builder renderer.
* @param renderer The base renderer in which the builder will be written
* @param classType The [TypeRef] representing the class for which a builder will be generated
* @param members The [Set] of members of [classType] which will be included in the builder
*/
class BuilderRenderer(
private val renderer: RendererBase,
private val classType: TypeRef,
private val members: Set<Member>
) { ... }
hll/codegen/src/main/kotlin/aws/sdk/kotlin/hll/codegen/rendering/RendererBase.kt
Outdated
Show resolved
Hide resolved
...ain/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/codegen/annotations/rendering/SchemaRenderer.kt
Outdated
Show resolved
Hide resolved
...degen/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/codegen/model/DynamoDbMapperTypes.kt
Outdated
Show resolved
Hide resolved
| aws.sdk.kotlin.hll.dynamodbmapper.codegen.operations.HighLevelOpsProcessorProvider | ||
| aws.sdk.kotlin.hll.dynamodbmapper.codegen.annotations.AnnotationsProcessorProvider | ||
|
|
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.
Comment: It is weird that our cross-mapper codegen module has multiple KSP processors and that we have to disable them by excludeProcessor. It'd be much simpler if we could includeProcessor or specify which we want by KSP arguments in Gradle somehow. 😖 I don't have a better suggestion, just saying it's weird.
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.
We spoke offline and both agreed it's weird, we're going to live with it and see if a solution becomes more necessary / clear.
Some possible solutions include using ksp DSL's arg to pass a mode (enabled / disabled) to the KSP processors. Another option is to replace excludeProcessor with a custom DSL function like singleProcessor(...) or includeProcessor(...)
|
A new generated diff is ready to view.
|
|
|
A new generated diff is ready to view.
|
…lin (#1451) * initial poc commit of DynamoDB Mapper (#1232) * add support for Mapper initialization (#1237) * implement mapper pipeline (#1266) * initial implementation of codegen for low-level operations/types (#1357) * initial implementation of secondary index support (#1375) * Create new codegen module and refactor annotation processor to use it (#1382) * feat: add Schema generator Gradle plugin (#1385) * Fix plugin test package * add attribute converters for "standard" values (#1381) * fix: schema generator plugin test module (#1394) * feat: annotation processor codegen configuration (#1392) * feat: add `@DynamoDbIgnore` annotation (#1402) * DDB Mapper filter expressions (runtime components) (#1401) * feat: basic annotation processing (#1399) * add DSL overloads, paginators, and better builder integration for DDB Mapper ops codegen (#1409) * chore: split dynamodb-mapper-codegen into two modules (#1414) * emit DDB_MAPPER business metric (#1426) * feat: setup DynamoDbMapper publication (#1419) * DDB Mapper filter expressions (codegen components) (#1424) * correct docs * mark every HLL/DDBM API experimental (#1428) * fix accidental inclusion of expression attribute members in high-level DynamoDB Mapper requests (#1432) * Upgrade to latest build plugin version * fix: various issues found during testing (#1450) * chore: update Athena changelog notes for 1.3.57 (2024-10-18) release (#1449) * feat: update AWS API models * feat: update AWS service endpoints metadata * chore: release 1.3.60 * chore: bump snapshot version to 1.3.61-SNAPSHOT * feat: initial release of Developer Preview of DynamoDB Mapper for Kotlin * Fix Kotlin gradle-plugin version * fix: ddb mapper tests (#1453) * Bump build plugin version --------- Co-authored-by: Matas <lauzmata@amazon.com> Co-authored-by: aws-sdk-kotlin-ci <aws-kotlin-sdk-automation@amazon.com>



Issue #
Description of changes
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.