mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2026-08-14 13:16:15 +00:00
fix in generate sealed workaround
This commit is contained in:
@@ -53,7 +53,7 @@ class Processor(
|
|||||||
val annotation = ksClassDeclaration.getGenerateSealedWorkaroundAnnotation
|
val annotation = ksClassDeclaration.getGenerateSealedWorkaroundAnnotation
|
||||||
val subClasses = ksClassDeclaration.resolveSubclasses(
|
val subClasses = ksClassDeclaration.resolveSubclasses(
|
||||||
searchIn = resolver.getAllFiles(),
|
searchIn = resolver.getAllFiles(),
|
||||||
allowNonSealed = annotation ?.includeNonSealedSubTypes ?: false
|
allowNonSealed = withNoSuchElementWorkaround(null) { annotation ?.includeNonSealedSubTypes } ?: false
|
||||||
).distinct()
|
).distinct()
|
||||||
val subClassesNames = subClasses.filter {
|
val subClassesNames = subClasses.filter {
|
||||||
when (it.classKind) {
|
when (it.classKind) {
|
||||||
@@ -165,15 +165,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 = runCatching {
|
val prefix = withNoSuchElementWorkaround(null) { (it.getGenerateSealedWorkaroundAnnotation) ?.prefix } ?.takeIf {
|
||||||
(it.getGenerateSealedWorkaroundAnnotation) ?.prefix
|
|
||||||
}.getOrElse {
|
|
||||||
if (it is NoSuchElementException) {
|
|
||||||
""
|
|
||||||
} else {
|
|
||||||
throw it
|
|
||||||
}
|
|
||||||
} ?.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") {
|
||||||
|
|||||||
Reference in New Issue
Block a user