[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
@@ -0,0 +1,31 @@
/*
* Copyright 2010-2024 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.analysis.test.framework.services.configuration
import org.jetbrains.kotlin.test.services.TestService
import org.jetbrains.kotlin.test.services.TestServices
class AnalysisApiIndexingConfiguration(val binaryLibraryIndexingMode: AnalysisApiBinaryLibraryIndexingMode) : TestService
/**
* Specifies the indexing behavior of [org.jetbrains.kotlin.analysis.providers.KotlinDeclarationProvider] for *test module* binary
* libraries.
*/
enum class AnalysisApiBinaryLibraryIndexingMode {
/**
* Stubs should be built for declarations from binary libraries. These stubs should be indexed. This is necessary when FIR symbols from
* binary libraries are deserialized from stubs.
*/
INDEX_STUBS,
/**
* Binary library declarations should not be indexed. This is the correct option when FIR symbols from binary libraries are deserialized
* from class files.
*/
NO_INDEXING,
}
val TestServices.libraryIndexingConfiguration: AnalysisApiIndexingConfiguration by TestServices.testServiceAccessor()