All Downloads are FREE. Search and download functionalities are using the official Maven repository.

tech.carcadex.kotlinbukkitkit.genref.processor.GenRefProcessor.kt Maven / Gradle / Ivy

package tech.carcadex.kotlinbukkitkit.genref.processor

import com.google.devtools.ksp.KspExperimental
import com.google.devtools.ksp.isAnnotationPresent
import com.google.devtools.ksp.processing.CodeGenerator
import com.google.devtools.ksp.processing.KSPLogger
import com.google.devtools.ksp.processing.Resolver
import com.google.devtools.ksp.processing.SymbolProcessor
import com.google.devtools.ksp.symbol.KSAnnotated
import com.google.devtools.ksp.symbol.KSFunctionDeclaration
import com.google.devtools.ksp.validate
import tech.carcadex.kotlinbukkitkit.genref.plugin.PluginVisitor
import tech.carcadex.kotlinbukkitkit.genref.plugin.annotations.Plugin

class GenRefProcessor(private val codeGenerator: CodeGenerator,
                      private val logger: KSPLogger) : SymbolProcessor {
   // private var invoked = false

    @OptIn(KspExperimental::class)
    override fun process(resolver: Resolver): List {
     //  if(invoked) return emptyList()
        val visitor = PluginVisitor(codeGenerator, logger, resolver)
        resolver.getAllFiles()
            .filter { it.validate() }
            .filter {
                it.declarations.any { it is KSFunctionDeclaration && it.validate() && it.isAnnotationPresent(Plugin::class) }
            }.firstOrNull()?.accept(visitor, Unit)

       // invoked = true
        return emptyList()
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy