mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2026-03-11 12:52:23 +00:00
generate docs for a lot of API (test try)
This commit is contained in:
@@ -6,6 +6,17 @@ import com.squareup.kotlinpoet.ClassName
|
||||
import com.squareup.kotlinpoet.asTypeName
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
/**
|
||||
* Safely retrieves a [ClassName] from a [KClass] getter, handling cases where the type is not
|
||||
* yet available during annotation processing (KSP).
|
||||
*
|
||||
* When [KSTypeNotPresentException] is caught, it extracts the class name information from the
|
||||
* exception's [com.google.devtools.ksp.symbol.KSType] to construct a [ClassName].
|
||||
*
|
||||
* @param classnameGetter A lambda that returns the [KClass] to convert
|
||||
* @return A KotlinPoet [ClassName] representing the class
|
||||
* @throws Throwable If an exception other than [KSTypeNotPresentException] occurs
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@OptIn(KspExperimental::class)
|
||||
inline fun safeClassName(classnameGetter: () -> KClass<*>) = runCatching {
|
||||
|
||||
@@ -2,6 +2,13 @@ package dev.inmo.micro_ksp.generator
|
||||
|
||||
import com.google.devtools.ksp.symbol.KSClassDeclaration
|
||||
|
||||
/**
|
||||
* Recursively resolves all subclasses of this sealed class declaration.
|
||||
* For sealed classes, it traverses the entire hierarchy of sealed subclasses.
|
||||
* For non-sealed classes (leaf nodes), it returns the class itself.
|
||||
*
|
||||
* @return A list of all concrete (non-sealed) subclass declarations in the hierarchy
|
||||
*/
|
||||
fun KSClassDeclaration.resolveSubclasses(): List<KSClassDeclaration> {
|
||||
return (getSealedSubclasses().flatMap {
|
||||
it.resolveSubclasses()
|
||||
|
||||
Reference in New Issue
Block a user