Changes in the compiler needed to run KAPT 4 (KT-51982)

This commit is contained in:
Pavel Mikhailovskii
2023-07-31 18:07:40 +00:00
committed by Space Team
parent dac8688a29
commit 84bf411cc3
5 changed files with 30 additions and 6 deletions
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.fir.extensions
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.extensions.ProjectExtensionDescriptor
@@ -13,7 +14,22 @@ abstract class FirAnalysisHandlerExtension {
companion object : ProjectExtensionDescriptor<FirAnalysisHandlerExtension>(
"org.jetbrains.kotlin.fir.firAnalyzeCompleteHandlerExtension",
FirAnalysisHandlerExtension::class.java
)
) {
/**
* Applies [FirAnalysisHandlerExtension] instances to a project
* @receiver the project to analyze
* @param configuration compiler configuration
* @return [null] if no applicable extensions were found, [true] if all applicable extensions returned [true] from [doAnalysis],
* [false] if any applicable extension returned [false]
*
* @see FirAnalysisHandlerExtension.isApplicable
* @see FirAnalysisHandlerExtension.doAnalysis
*/
fun analyze(project: Project, configuration: CompilerConfiguration): Boolean? {
val extensions = FirAnalysisHandlerExtension.getInstances(project).filter { it.isApplicable(configuration) }
return if (extensions.isEmpty()) null else extensions.all { it.doAnalysis(configuration) }
}
}
/**
* Checks whether [doAnalysis] should be called
@@ -25,7 +41,8 @@ abstract class FirAnalysisHandlerExtension {
/**
* Performs code analysis
* @param configuration compiler configuration
* @return true if analysis completed successfully. There can be different causes of failure, an incorrect configuration for example.
* @return [true] if analysis completed successfully, [false] otherwise.
* There can be different causes of failure, an incorrect configuration for example.
* A failure means that there's no reason to continue building the project.
*/
abstract fun doAnalysis(configuration: CompilerConfiguration): Boolean