[AA] Introduce AnalysisApiIndexingConfiguration test service

- The configuration allows the test infrastructure to decide whether to
  index binary libraries to stubs (when stub-based deserialized symbol
  providers are used) or to skip indexing (when class file-based
  deserialization is used).
- The information is needed in `AnalysisApiBaseTestServiceRegistrar`,
  where the `KotlinStaticDeclarationProviderFactory` is created. This
  service registrar shouldn't access `LLFirLibrarySymbolProviderFactory`
  and so checking the library symbol provider factory wasn't an option.
- Another alternative was adding a property to
  `AnalysisApiTestConfigurator`. However, this then requires passing the
  property to `AnalysisApiBaseTestServiceRegistrar`, because it doesn't
  have access to the configurator out of the box. This however goes
  against the design of our service registrars, which generally only
  access test services. So adding a test service seemed like the best
  solution.

^KT-65960
This commit is contained in:
Marco Pennekamp
2024-02-19 23:39:55 +01:00
committed by Space Team
parent d4278250e6
commit 878eba7d52
10 changed files with 63 additions and 1 deletions
@@ -18,6 +18,9 @@ object StandaloneModeConfigurator : StandaloneModeConfiguratorBase() {
override fun configureTest(builder: TestConfigurationBuilder, disposable: Disposable) {
sourceConfigurator.configureTest(builder, disposable)
// `StandaloneModeConfiguratorBase` is ordered last so that it overrules the source test configuration.
super.configureTest(builder, disposable)
}
private val sourceConfigurator = AnalysisApiFirSourceTestConfigurator(analyseInDependentSession = false)
@@ -5,8 +5,12 @@
package org.jetbrains.kotlin.analysis.api.standalone.fir.test.configurators
import com.intellij.openapi.Disposable
import org.jetbrains.kotlin.analysis.test.framework.services.configuration.AnalysisApiBinaryLibraryIndexingMode
import org.jetbrains.kotlin.analysis.test.framework.services.configuration.AnalysisApiIndexingConfiguration
import org.jetbrains.kotlin.analysis.test.framework.test.configurators.AnalysisApiTestConfigurator
import org.jetbrains.kotlin.analysis.test.framework.test.configurators.FrontendKind
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
abstract class StandaloneModeConfiguratorBase : AnalysisApiTestConfigurator() {
override val analyseInDependentSession: Boolean get() = false
@@ -14,4 +18,10 @@ abstract class StandaloneModeConfiguratorBase : AnalysisApiTestConfigurator() {
override val testPrefix: String
get() = "standalone.fir"
}
override fun configureTest(builder: TestConfigurationBuilder, disposable: Disposable) {
builder.apply {
useAdditionalService { AnalysisApiIndexingConfiguration(AnalysisApiBinaryLibraryIndexingMode.NO_INDEXING) }
}
}
}
@@ -30,6 +30,8 @@ import org.jetbrains.kotlin.test.services.configuration.ExternalAnnotationsEnvir
object StandaloneModeLibraryBinaryTestConfigurator : StandaloneModeConfiguratorBase() {
override fun configureTest(builder: TestConfigurationBuilder, disposable: Disposable) {
super.configureTest(builder, disposable)
with(builder) {
configureOptionalTestCompilerPlugin()
useConfigurators(::AnalysisApiJvmEnvironmentConfigurator)