[KAPT4] KT-51982 Implement generation of @Metadata annotations in Java stubs

Also adds rendering of @Metadata annotations in Kapt3 and Kapt4 tests
(currently disabled for a few tests).

Co-authored-by: Alexander Udalov <alexander.udalov@jetbrains.com>
This commit is contained in:
strangepleasures
2023-07-31 23:09:08 +02:00
committed by Space Team
parent f40fc1b0c6
commit 2423b7b62f
250 changed files with 15438 additions and 81 deletions
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.test.utils.withExtension
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance
import java.io.File
import java.util.*
import org.jetbrains.kotlin.kapt3.test.handlers.renderMetadata
internal class Kapt4Handler(testServices: TestServices) : AnalysisHandler<Kapt4ContextBinaryArtifact>(
testServices,
@@ -115,7 +116,7 @@ internal class Kapt4Handler(testServices: TestServices) : AnalysisHandler<Kapt4C
): List<JCTree.JCCompilationUnit> {
val (kaptContext, kaptStubs) = info
val convertedFiles = kaptStubs.mapIndexed { index, stub ->
val sourceFile = createTempJavaFile("stub$index.java", stub.file.prettyPrint(kaptContext.context))
val sourceFile = createTempJavaFile("stub$index.java", stub.file.prettyPrint(kaptContext.context, ::renderMetadata))
stub.writeMetadataIfNeeded(forSource = sourceFile)
sourceFile
}