Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
a51de4b
Create codegen module
lauzadis Aug 9, 2024
0a779a1
Create codegen module
lauzadis Aug 9, 2024
011f367
Add tests and .api
lauzadis Aug 9, 2024
75e208a
Bootstrap
lauzadis Aug 9, 2024
d8c65c9
tests
lauzadis Aug 9, 2024
5edef54
Fix package name in StringsTest
lauzadis Aug 9, 2024
df80d66
Latest
lauzadis Aug 12, 2024
3d5818e
Rendering correctly now
lauzadis Aug 12, 2024
73514a5
Small style changes
lauzadis Aug 12, 2024
ba04d3e
ktlint
lauzadis Aug 12, 2024
dbd737e
ktlint
lauzadis Aug 12, 2024
1da4704
ktlint
lauzadis Aug 12, 2024
48455a9
Remove unused types
lauzadis Aug 12, 2024
77f0792
StringMap -> stringMap
lauzadis Aug 12, 2024
725a391
Remove old-form codegen
lauzadis Aug 12, 2024
77c3264
cleanup
lauzadis Aug 12, 2024
a0134e0
KDocs
lauzadis Aug 12, 2024
165e59b
apiDump
lauzadis Aug 12, 2024
3513113
Add extra metadata
lauzadis Aug 12, 2024
e995954
Remove unused function
lauzadis Aug 12, 2024
a1cfc8e
Pass around a `codeGeneratorName`
lauzadis Aug 13, 2024
f5cdd9a
annotations -> annotatedClasses
lauzadis Aug 13, 2024
54ec0b3
rename: AnnotationRenderer -> SchemaRenderer, add common BuilderRende…
lauzadis Aug 13, 2024
c8148fc
Promote `internal` objects back to `public`
lauzadis Aug 13, 2024
1176517
Check property nullability when rendering build method (specifically …
lauzadis Aug 13, 2024
aac0fda
Add TODOs
lauzadis Aug 13, 2024
3f566a6
Replace #L with #T where appropriate
lauzadis Aug 13, 2024
a0f0bfc
ktlint
lauzadis Aug 13, 2024
8327568
Add `RendererBase.use { ... }`
lauzadis Aug 13, 2024
48c4206
Combine operations and annotation processor codegen into common codeg…
lauzadis Aug 13, 2024
7ea934e
Temporarily disable annotation-processor-test
lauzadis Aug 13, 2024
171e47a
Configure `excludeProcessor`
lauzadis Aug 13, 2024
47499cb
Relocate to dynamodbmapper.codegen.* package
lauzadis Aug 14, 2024
3ea7b6f
Break out Types and DynamoDbMapperTypes
lauzadis Aug 14, 2024
599c9b1
ktlint
lauzadis Aug 14, 2024
addb7c7
Handle auto-import of nested types
lauzadis Aug 14, 2024
69b7c5f
ktlint
lauzadis Aug 14, 2024
f010bb5
Fix typo in KDocs
lauzadis Aug 14, 2024
42aebb2
Replace more #L with #T
lauzadis Aug 14, 2024
1788f2a
Replace more #L with #T
lauzadis Aug 14, 2024
5a39f82
Don't explicitly import types from the `kotlin` namespace
lauzadis Aug 14, 2024
e63b9e1
Remove explicit import on user class
lauzadis Aug 14, 2024
b68fa5e
ktlint
lauzadis Aug 14, 2024
5d698ca
Use `kotlin` function
lauzadis Aug 16, 2024
5c2915e
Add two new Type.from methods
lauzadis Aug 16, 2024
98b59fb
Use #T in builder docs
lauzadis Aug 16, 2024
c971520
classType = Type.from(classDeclaration)
lauzadis Aug 16, 2024
881a7a8
apiDump
lauzadis Aug 16, 2024
f4f399a
Move `rendererName` to `renderCtx`
lauzadis Aug 16, 2024
9c63c47
Add single-line `docs(...)` function and fix API validation settings
lauzadis Aug 16, 2024
d3e3aeb
Further nesting of types and rename to `MapperTypes`
lauzadis Aug 16, 2024
1da7f9a
Remove unused types
lauzadis Aug 16, 2024
345fd8e
exclude annotation processor in ops-codegen
lauzadis Aug 16, 2024
fbd7ba1
rename module `codegen` to `hll-codegen`
lauzadis Aug 16, 2024
930fb53
rename module `codegen` to `hll-codegen`
lauzadis Aug 16, 2024
3513aa6
Add `type.baseName`
lauzadis Aug 16, 2024
1ca559c
Move [Member] to shared codegen module and clean up BuilderRenderer
lauzadis Aug 16, 2024
a1b54b6
ktlint
lauzadis Aug 16, 2024
a5d6c9d
Remove unnecessary visibility modifiers
lauzadis Aug 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions hll/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import aws.sdk.kotlin.gradle.kmp.*
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

description = "High-level libraries for the AWS SDK for Kotlin"
extra["displayName"] = "AWS :: SDK :: Kotlin :: HLL"
extra["moduleName"] = "aws.sdk.kotlin.hll"

// FIXME 🔽🔽🔽 This is all copied from :aws-runtime and should be commonized 🔽🔽🔽

Expand Down Expand Up @@ -85,8 +87,8 @@ apiValidation {
val availableSubprojects = subprojects.map { it.name }.toSet()

ignoredProjects += listOf(
"dynamodb-mapper-annotation-processor",
"hll-codegen",
"dynamodb-mapper-annotation-processor-test",
"dynamodb-mapper-ops-codegen",
"dynamodb-mapper-codegen",
).filter { it in availableSubprojects } // Some projects may not be in the build depending on bootstrapping
}

This file was deleted.

This file was deleted.

This file was deleted.

24 changes: 24 additions & 0 deletions hll/dynamodb-mapper/dynamodb-mapper-codegen/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

description = "DynamoDbMapper code generation"
extra["displayName"] = "AWS :: SDK :: Kotlin :: HLL :: DynamoDbMapper :: Codegen"
extra["moduleName"] = "aws.sdk.kotlin.hll.dynamodbmapper.codegen"

plugins {
alias(libs.plugins.kotlin.jvm)
}

dependencies {
implementation(libs.ksp.api)
implementation(project(":hll:hll-codegen"))
implementation(project(":hll:dynamodb-mapper:dynamodb-mapper-annotations"))
implementation(project(":services:dynamodb"))

testImplementation(libs.junit.jupiter)
testImplementation(libs.junit.jupiter.params)
testImplementation(libs.kotest.assertions.core.jvm)
testImplementation(libs.kotlin.test.junit5)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package aws.sdk.kotlin.hll.dynamodbmapper.codegen.annotations

import aws.sdk.kotlin.hll.codegen.core.CodeGeneratorFactory
import aws.sdk.kotlin.hll.dynamodbmapper.DynamoDbItem
import aws.sdk.kotlin.hll.dynamodbmapper.codegen.annotations.rendering.HighLevelRenderer
import com.google.devtools.ksp.processing.*
import com.google.devtools.ksp.symbol.*
import com.google.devtools.ksp.validate

private val annotationName = DynamoDbItem::class.qualifiedName!!

class AnnotationsProcessor(private val environment: SymbolProcessorEnvironment) : SymbolProcessor {
private var invoked = false
private val logger = environment.logger
private val codeGenerator = environment.codeGenerator
private val codeGeneratorFactory = CodeGeneratorFactory(codeGenerator, logger)

override fun process(resolver: Resolver): List<KSAnnotated> {
if (invoked) {
return listOf()
}
invoked = true

logger.info("Searching for symbols annotated with $annotationName")
val annotated = resolver.getSymbolsWithAnnotation(annotationName)
val invalid = annotated.filterNot { it.validate() }.toList()
logger.info("Found invalid classes $invalid")

val annotatedClasses = annotated
.toList()
.also { logger.info("Found annotated classes: $it") }
.filterIsInstance<KSClassDeclaration>()
.filter { it.validate() }

HighLevelRenderer(annotatedClasses, logger, codeGeneratorFactory).render()

return invalid
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package aws.sdk.kotlin.hll.dynamodbmapper.processor
package aws.sdk.kotlin.hll.dynamodbmapper.codegen.annotations

import com.google.devtools.ksp.processing.SymbolProcessorEnvironment
import com.google.devtools.ksp.processing.SymbolProcessorProvider

public class MapperProcessorProvider : SymbolProcessorProvider {
override fun create(environment: SymbolProcessorEnvironment): MapperProcessor = MapperProcessor(environment)
class AnnotationsProcessorProvider : SymbolProcessorProvider {
override fun create(environment: SymbolProcessorEnvironment): AnnotationsProcessor = AnnotationsProcessor(environment)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package aws.sdk.kotlin.hll.dynamodbmapper.codegen.annotations.rendering

import aws.sdk.kotlin.hll.codegen.core.CodeGeneratorFactory
import aws.sdk.kotlin.hll.codegen.rendering.RenderContext
import com.google.devtools.ksp.processing.KSPLogger
import com.google.devtools.ksp.symbol.KSClassDeclaration

/**
* The parent renderer for all codegen from this package. This class orchestrates the various sub-renderers.
* @param annotatedClasses A list of annotated classes
*/
class HighLevelRenderer(
private val annotatedClasses: List<KSClassDeclaration>,
private val logger: KSPLogger,
private val codegenFactory: CodeGeneratorFactory,
) {
fun render() {
annotatedClasses.forEach {
logger.info("Processing annotation on ${it.simpleName}")
val renderCtx = RenderContext(logger, codegenFactory, "${it.packageName.asString()}.mapper.schemas", "dynamodb-mapper-annotation-processor")
val annotation = SchemaRenderer(it, renderCtx)
annotation.render()
}
}
}
Loading