o_utils.ksp.generator.0.23.0.source-code.WalkOnKSFiles.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of micro_utils.ksp.generator Show documentation
Show all versions of micro_utils.ksp.generator Show documentation
It is set of projects with micro tools for avoiding of routines coding
The newest version!
package dev.inmo.micro_ksp.generator
import com.google.devtools.ksp.getAllSuperTypes
import com.google.devtools.ksp.symbol.KSAnnotated
import com.google.devtools.ksp.symbol.KSClassDeclaration
import com.google.devtools.ksp.symbol.KSDeclarationContainer
import com.google.devtools.ksp.symbol.KSFile
fun KSClassDeclaration.findSubClasses(subSymbol: KSAnnotated): Sequence {
return when (subSymbol) {
is KSClassDeclaration -> if (subSymbol.getAllSuperTypes().map { it.declaration }.contains(this)) {
sequenceOf(subSymbol)
} else {
sequenceOf()
}
else -> sequenceOf()
} + if (subSymbol is KSDeclarationContainer) {
subSymbol.declarations.flatMap {
findSubClasses(it)
}
} else {
sequenceOf()
}
}
fun KSClassDeclaration.findSubClasses(files: Sequence): Sequence {
return files.flatMap {
findSubClasses(it)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy