mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-22 16:23:50 +00:00
hotfix due to deprecated annotation
This commit is contained in:
parent
ee2521cb01
commit
c5dbd10335
@ -0,0 +1,11 @@
|
|||||||
|
package dev.inmo.micro_utils.ksp.sealed.generator
|
||||||
|
|
||||||
|
import com.google.devtools.ksp.KspExperimental
|
||||||
|
import com.google.devtools.ksp.getAnnotationsByType
|
||||||
|
import com.google.devtools.ksp.symbol.KSClassDeclaration
|
||||||
|
import dev.inmo.micro_utils.ksp.sealed.GenerateSealedWorkaround
|
||||||
|
import dev.inmo.microutils.kps.sealed.GenerateSealedWorkaround as OldGenerateSealedWorkaround
|
||||||
|
|
||||||
|
@OptIn(KspExperimental::class)
|
||||||
|
val KSClassDeclaration.getGenerateSealedWorkaroundAnnotation
|
||||||
|
get() = (getAnnotationsByType(GenerateSealedWorkaround::class).firstOrNull() ?: getAnnotationsByType(OldGenerateSealedWorkaround::class).firstOrNull())
|
@ -53,10 +53,10 @@ class Processor(
|
|||||||
ksClassDeclaration: KSClassDeclaration,
|
ksClassDeclaration: KSClassDeclaration,
|
||||||
resolver: Resolver
|
resolver: Resolver
|
||||||
) {
|
) {
|
||||||
val annotation = ksClassDeclaration.getAnnotationsByType(GenerateSealedWorkaround::class).first()
|
val annotation = ksClassDeclaration.getGenerateSealedWorkaroundAnnotation
|
||||||
val subClasses = ksClassDeclaration.resolveSubclasses(
|
val subClasses = ksClassDeclaration.resolveSubclasses(
|
||||||
searchIn = resolver.getAllFiles(),
|
searchIn = resolver.getAllFiles(),
|
||||||
allowNonSealed = annotation.includeNonSealedSubTypes
|
allowNonSealed = annotation ?.includeNonSealedSubTypes ?: false
|
||||||
).distinct()
|
).distinct()
|
||||||
val subClassesNames = subClasses.filter {
|
val subClassesNames = subClasses.filter {
|
||||||
when (it.classKind) {
|
when (it.classKind) {
|
||||||
@ -112,7 +112,7 @@ class Processor(
|
|||||||
@OptIn(KspExperimental::class)
|
@OptIn(KspExperimental::class)
|
||||||
override fun process(resolver: Resolver): List<KSAnnotated> {
|
override fun process(resolver: Resolver): List<KSAnnotated> {
|
||||||
(resolver.getSymbolsWithAnnotation(GenerateSealedWorkaround::class.qualifiedName!!)).filterIsInstance<KSClassDeclaration>().forEach {
|
(resolver.getSymbolsWithAnnotation(GenerateSealedWorkaround::class.qualifiedName!!)).filterIsInstance<KSClassDeclaration>().forEach {
|
||||||
val prefix = it.getAnnotationsByType(GenerateSealedWorkaround::class).first().prefix.takeIf {
|
val prefix = (it.getGenerateSealedWorkaroundAnnotation) ?.prefix ?.takeIf {
|
||||||
it.isNotEmpty()
|
it.isNotEmpty()
|
||||||
} ?: it.buildSubFileName.replaceFirst(it.simpleName.asString(), "")
|
} ?: it.buildSubFileName.replaceFirst(it.simpleName.asString(), "")
|
||||||
it.writeFile(prefix = prefix, suffix = "SealedWorkaround") {
|
it.writeFile(prefix = prefix, suffix = "SealedWorkaround") {
|
||||||
|
Loading…
Reference in New Issue
Block a user