org.jetbrains.kotlin.kapt4.Kapt4ContextForStubGeneration.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-annotation-processing-embeddable Show documentation
Show all versions of kotlin-annotation-processing-embeddable Show documentation
Annotation Processor for Kotlin (for using with embeddable compiler)
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.kapt4
import com.sun.tools.javac.tree.TreeMaker
import com.sun.tools.javac.util.Context
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
import org.jetbrains.kotlin.asJava.classes.KtLightClass
import org.jetbrains.kotlin.asJava.findFacadeClass
import org.jetbrains.kotlin.asJava.toLightClass
import org.jetbrains.kotlin.base.kapt3.KaptOptions
import org.jetbrains.kotlin.kapt3.base.KaptContext
import org.jetbrains.kotlin.kapt3.base.util.KaptLogger
import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.psi.KtFile
internal class Kapt4ContextForStubGeneration(
options: KaptOptions,
withJdk: Boolean,
logger: KaptLogger,
val analysisSession: KtAnalysisSession,
val files: List,
) : KaptContext(options, withJdk, logger) {
val classes: Iterable = buildSet {
files.flatMapTo(this) { file ->
file.children.filterIsInstance().mapNotNull {
it.toLightClass()
}
}
files.mapNotNullTo(this) { ktFile -> ktFile.findFacadeClass() }.distinct()
}
internal val treeMaker = TreeMaker.instance(context) as Kapt4TreeMaker
override fun preregisterTreeMaker(context: Context) {
Kapt4TreeMaker.preRegister(context)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy