-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add meta annotation support in Kotlin annotation processor (#431)
- Loading branch information
1 parent
74d9e5a
commit 7fb4faf
Showing
5 changed files
with
136 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
sdk-api-kotlin-gen/src/main/kotlin/dev/restate/sdk/kotlin/gen/MetaRestateAnnotation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) 2023 - Restate Software, Inc., Restate GmbH | ||
// | ||
// This file is part of the Restate Java SDK, | ||
// which is released under the MIT license. | ||
// | ||
// You can find a copy of the license in file LICENSE in the root | ||
// directory of this repository or package, or at | ||
// https://github.com/restatedev/sdk-java/blob/main/LICENSE | ||
package dev.restate.sdk.kotlin.gen | ||
|
||
import com.google.devtools.ksp.symbol.KSAnnotated | ||
import com.google.devtools.ksp.symbol.KSName | ||
import dev.restate.sdk.common.ServiceType | ||
|
||
internal data class MetaRestateAnnotation( | ||
val annotationName: KSName, | ||
val serviceType: ServiceType | ||
) { | ||
fun resolveName(annotated: KSAnnotated): String? = | ||
annotated.annotations | ||
.find { it.annotationType.resolve().declaration.qualifiedName == annotationName } | ||
?.arguments | ||
?.firstOrNull { it -> it.name?.getShortName() == "name" } | ||
?.value as String? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
sdk-api-kotlin-gen/src/test/kotlin/dev/restate/sdk/kotlin/MyMetaServiceAnnotation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (c) 2023 - Restate Software, Inc., Restate GmbH | ||
// | ||
// This file is part of the Restate Java SDK, | ||
// which is released under the MIT license. | ||
// | ||
// You can find a copy of the license in file LICENSE in the root | ||
// directory of this repository or package, or at | ||
// https://github.com/restatedev/sdk-java/blob/main/LICENSE | ||
package dev.restate.sdk.kotlin | ||
|
||
import dev.restate.sdk.annotation.Service | ||
|
||
@Service annotation class MyMetaServiceAnnotation(val name: String = "") |