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

godot.annotation.processor.compiler.CompilerDataProvider.kt Maven / Gradle / Ivy

There is a newer version: 0.10.0-4.3.0
Show newest version
package godot.annotation.processor.compiler

import com.google.devtools.ksp.processing.Resolver
import org.jetbrains.kotlin.com.intellij.openapi.project.Project

internal object CompilerDataProvider {
    private var _project: Project? = null
    val project: Project
        get() = _project ?: throw UninitializedPropertyAccessException("CompilerDataProvider not yet initialized")

    private var _srcDirs: List? = null
    val srcDirs: List
        get() = _srcDirs ?: throw UninitializedPropertyAccessException("CompilerDataProvider not yet initialized")

    fun init(resolver: Resolver, sourceDirs: List) {
        //get compilation project through reflection
        //the underlying compiler plugin of ksp is a AnalysisExtension which provides the project
        //here we just access it to make use of it to gather all psi files which are needed for the psi based default value extraction
        _project = resolver::class.java.getDeclaredField("project").let {
            it.isAccessible = true
            (it.get(resolver) as Project)
        }
        _srcDirs = sourceDirs
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy