Fix explicit api issues in analysis modules
Explicit api mode was not working due to the bug. ^KT-57653
This commit is contained in:
committed by
Space Team
parent
1860683a71
commit
d57623891d
+3
-3
@@ -338,11 +338,11 @@ public class KotlinStaticDeclarationProviderFactory(
|
||||
*
|
||||
* Otherwise, each test would start indexing of stdlib from scratch,
|
||||
* and under the lock which makes tests extremely slow*/
|
||||
class KotlinFakeClsStubsCache {
|
||||
public class KotlinFakeClsStubsCache {
|
||||
private val fakeFileClsStubs = CollectionFactory.createConcurrentWeakValueMap<String, List<KotlinFileStubImpl>>()
|
||||
|
||||
companion object {
|
||||
fun processAdditionalRoot(root: VirtualFile, storage: (VirtualFile) -> List<KotlinFileStubImpl>): List<KotlinFileStubImpl>? {
|
||||
public companion object {
|
||||
public fun processAdditionalRoot(root: VirtualFile, storage: (VirtualFile) -> List<KotlinFileStubImpl>): List<KotlinFileStubImpl>? {
|
||||
val service = ApplicationManager.getApplication().getService(KotlinFakeClsStubsCache::class.java) ?: return null
|
||||
if (service.fakeFileClsStubs[root.path] == null) {
|
||||
service.fakeFileClsStubs[root.path] = storage(root)
|
||||
|
||||
@@ -3,10 +3,6 @@ plugins {
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
explicitApiWarning()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(intellijCore())
|
||||
implementation(project(":compiler:psi"))
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.analysis.api.standalone.fir.test
|
||||
|
||||
import org.jetbrains.kotlin.analysis.test.framework.test.configurators.*
|
||||
|
||||
object AnalysisApiFirStandaloneModeTestConfiguratorFactory : AnalysisApiTestConfiguratorFactory() {
|
||||
public object AnalysisApiFirStandaloneModeTestConfiguratorFactory : AnalysisApiTestConfiguratorFactory() {
|
||||
override fun createConfigurator(data: AnalysisApiTestConfiguratorFactoryData): AnalysisApiTestConfigurator {
|
||||
requireSupported(data)
|
||||
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
||||
import org.jetbrains.kotlin.test.services.TestModuleStructure
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
|
||||
object StandaloneModeConfigurator : AnalysisApiTestConfigurator() {
|
||||
public object StandaloneModeConfigurator : AnalysisApiTestConfigurator() {
|
||||
override val analyseInDependentSession: Boolean get() = false
|
||||
override val frontendKind: FrontendKind get() = FrontendKind.Fir
|
||||
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.analysis.test.framework.services.environmentManager
|
||||
import org.jetbrains.kotlin.analysis.test.framework.test.configurators.AnalysisApiTestServiceRegistrar
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
|
||||
object StandaloneModeTestServiceRegistrar : AnalysisApiTestServiceRegistrar() {
|
||||
public object StandaloneModeTestServiceRegistrar : AnalysisApiTestServiceRegistrar() {
|
||||
override fun registerProjectExtensionPoints(project: MockProject, testServices: TestServices) {
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.assertions
|
||||
|
||||
abstract class AbstractPsiDeclarationProviderTest : AbstractAnalysisApiBasedSingleModuleTest() {
|
||||
public abstract class AbstractPsiDeclarationProviderTest : AbstractAnalysisApiBasedSingleModuleTest() {
|
||||
override fun doTestByFileStructure(ktFiles: List<KtFile>, module: TestModule, testServices: TestServices) {
|
||||
val mainKtFile = ktFiles.singleOrNull() ?: ktFiles.firstOrNull { it.name == "main.kt" } ?: ktFiles.first()
|
||||
val caretPosition = testServices.expressionMarkerProvider.getCaretPosition(mainKtFile)
|
||||
|
||||
+2
-2
@@ -12,8 +12,8 @@ import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.KtNamedFunction
|
||||
import org.jetbrains.kotlin.psi.KtParameter
|
||||
|
||||
object TestPsiElementRenderer {
|
||||
fun render(psiElement: PsiElement): String = when (psiElement) {
|
||||
public object TestPsiElementRenderer {
|
||||
public fun render(psiElement: PsiElement): String = when (psiElement) {
|
||||
is KtNamedFunction -> buildString {
|
||||
append("KtNamedFunction:")
|
||||
append(psiElement.name)
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.analysis.api.lifetime.withValidityAssertion
|
||||
import org.jetbrains.kotlin.analysis.api.scopes.KtScope
|
||||
|
||||
public abstract class KtSymbolFromResolveExtensionProvider : KtAnalysisSessionComponent() {
|
||||
abstract fun getResolveExtensionScopeWithTopLevelDeclarations(): KtScope
|
||||
public abstract fun getResolveExtensionScopeWithTopLevelDeclarations(): KtScope
|
||||
}
|
||||
|
||||
public interface KtSymbolFromResolveExtensionProviderMixIn : KtAnalysisSessionMixIn {
|
||||
@@ -19,7 +19,7 @@ public interface KtSymbolFromResolveExtensionProviderMixIn : KtAnalysisSessionMi
|
||||
* @see org.jetbrains.kotlin.analysis.api.resolve.extensions.KtResolveExtension
|
||||
* @see org.jetbrains.kotlin.analysis.api.resolve.extensions.KtResolveExtensionProvider
|
||||
*/
|
||||
fun getResolveExtensionScopeWithTopLevelDeclarations(): KtScope = withValidityAssertion {
|
||||
public fun getResolveExtensionScopeWithTopLevelDeclarations(): KtScope = withValidityAssertion {
|
||||
analysisSession.resolveExtensionProvider.getResolveExtensionScopeWithTopLevelDeclarations()
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.name.FqName
|
||||
* @see KtResolveExtensionFile
|
||||
* @see KtResolveExtensionProvider
|
||||
*/
|
||||
abstract class KtResolveExtension {
|
||||
public abstract class KtResolveExtension {
|
||||
/**
|
||||
* Get the list of files that should be generated for the module.
|
||||
*
|
||||
@@ -32,7 +32,7 @@ abstract class KtResolveExtension {
|
||||
* @see KtResolveExtensionFile
|
||||
* @see KtResolveExtension
|
||||
*/
|
||||
abstract fun getKtFiles(): List<KtResolveExtensionFile>
|
||||
public abstract fun getKtFiles(): List<KtResolveExtensionFile>
|
||||
|
||||
/**
|
||||
* Returns a [ModificationTracker], which controls the validity lifecycle of the files provided by [getKtFiles].
|
||||
@@ -42,7 +42,7 @@ abstract class KtResolveExtension {
|
||||
*
|
||||
* @see KtResolveExtension
|
||||
*/
|
||||
abstract fun getModificationTracker(): ModificationTracker
|
||||
public abstract fun getModificationTracker(): ModificationTracker
|
||||
|
||||
/**
|
||||
* Returns the set of packages that are contained in the files provided by [getKtFiles].
|
||||
@@ -52,5 +52,5 @@ abstract class KtResolveExtension {
|
||||
*
|
||||
* @see KtResolveExtension
|
||||
*/
|
||||
abstract fun getContainedPackages(): Set<FqName>
|
||||
public abstract fun getContainedPackages(): Set<FqName>
|
||||
}
|
||||
+7
-8
@@ -18,7 +18,7 @@ import org.jetbrains.kotlin.name.Name
|
||||
*
|
||||
* @see KtResolveExtension
|
||||
*/
|
||||
abstract class KtResolveExtensionFile {
|
||||
public abstract class KtResolveExtensionFile {
|
||||
/**
|
||||
* The name a Kotlin file which will be generated.
|
||||
*
|
||||
@@ -28,7 +28,7 @@ abstract class KtResolveExtensionFile {
|
||||
*
|
||||
* @see KtResolveExtensionFile
|
||||
*/
|
||||
abstract fun getFileName(): String
|
||||
public abstract fun getFileName(): String
|
||||
|
||||
/**
|
||||
* [FqName] of the package specified in the file
|
||||
@@ -39,7 +39,7 @@ abstract class KtResolveExtensionFile {
|
||||
*
|
||||
* @see KtResolveExtensionFile
|
||||
*/
|
||||
abstract fun getFilePackageName(): FqName
|
||||
public abstract fun getFilePackageName(): FqName
|
||||
|
||||
/**
|
||||
* Returns the set of top-level classifier (classes, interfaces, objects, and type-aliases) names in the file.
|
||||
@@ -48,7 +48,7 @@ abstract class KtResolveExtensionFile {
|
||||
*
|
||||
* @see KtResolveExtensionFile
|
||||
*/
|
||||
abstract fun getTopLevelClassifierNames(): Set<Name>
|
||||
public abstract fun getTopLevelClassifierNames(): Set<Name>
|
||||
|
||||
/**
|
||||
* Returns the set of top-level callable (functions and properties) names in the file.
|
||||
@@ -57,7 +57,7 @@ abstract class KtResolveExtensionFile {
|
||||
*
|
||||
* @see KtResolveExtensionFile
|
||||
*/
|
||||
abstract fun getTopLevelCallableNames(): Set<Name>
|
||||
public abstract fun getTopLevelCallableNames(): Set<Name>
|
||||
|
||||
/**
|
||||
* Creates the generated Kotlin source file text.
|
||||
@@ -74,7 +74,7 @@ abstract class KtResolveExtensionFile {
|
||||
*
|
||||
* @see KtResolveExtensionFile
|
||||
*/
|
||||
abstract fun buildFileText(): String
|
||||
public abstract fun buildFileText(): String
|
||||
|
||||
/**
|
||||
* Creates a [KtResolveExtensionReferencePsiTargetsProvider] for this [KtResolveExtensionFile].
|
||||
@@ -82,6 +82,5 @@ abstract class KtResolveExtensionFile {
|
||||
* @see KtResolveExtensionReferencePsiTargetsProvider
|
||||
* @see KtResolveExtensionFile
|
||||
*/
|
||||
abstract fun createPsiTargetsProvider(): KtResolveExtensionReferencePsiTargetsProvider
|
||||
|
||||
public abstract fun createPsiTargetsProvider(): KtResolveExtensionReferencePsiTargetsProvider
|
||||
}
|
||||
+6
-5
@@ -15,7 +15,7 @@ import org.jetbrains.kotlin.analysis.project.structure.KtModule
|
||||
*
|
||||
* All member implementations should consider caching the results for subsequent invocations.
|
||||
*/
|
||||
abstract class KtResolveExtensionProvider {
|
||||
public abstract class KtResolveExtensionProvider {
|
||||
/**
|
||||
* Provides a list of [KtResolveExtension]s for a given [KtModule].
|
||||
*
|
||||
@@ -25,12 +25,13 @@ abstract class KtResolveExtensionProvider {
|
||||
*
|
||||
* Implementation cannot use the Kotlin resolve inside, as this function is called during session initialization, so Analysis API access is forbidden.
|
||||
*/
|
||||
abstract fun provideExtensionsFor(module: KtModule): List<KtResolveExtension>
|
||||
public abstract fun provideExtensionsFor(module: KtModule): List<KtResolveExtension>
|
||||
|
||||
companion object {
|
||||
val EP_NAME = ExtensionPointName<KtResolveExtensionProvider>("org.jetbrains.kotlin.ktResolveExtensionProvider")
|
||||
public companion object {
|
||||
public val EP_NAME: ExtensionPointName<KtResolveExtensionProvider> =
|
||||
ExtensionPointName<KtResolveExtensionProvider>("org.jetbrains.kotlin.ktResolveExtensionProvider")
|
||||
|
||||
fun provideExtensionsFor(module: KtModule): List<KtResolveExtension> {
|
||||
public fun provideExtensionsFor(module: KtModule): List<KtResolveExtension> {
|
||||
return EP_NAME.getExtensionList(module.project).flatMap { it.provideExtensionsFor(module) }
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -9,7 +9,7 @@ import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtSymbol
|
||||
|
||||
abstract class KtResolveExtensionReferencePsiTargetsProvider {
|
||||
public abstract class KtResolveExtensionReferencePsiTargetsProvider {
|
||||
/**
|
||||
* Provides a [PsiElement] where `reference.resolveTo` will lead for a [symbol]
|
||||
*
|
||||
@@ -18,5 +18,5 @@ abstract class KtResolveExtensionReferencePsiTargetsProvider {
|
||||
*
|
||||
* Returned [PsiElement] will be used as a navigation target for a reference inside the IDE.
|
||||
*/
|
||||
abstract fun KtAnalysisSession.getReferenceTargetsForSymbol(symbol: KtSymbol): Collection<PsiElement>
|
||||
public abstract fun KtAnalysisSession.getReferenceTargetsForSymbol(symbol: KtSymbol): Collection<PsiElement>
|
||||
}
|
||||
+1
-1
@@ -12,7 +12,7 @@ import org.jetbrains.kotlin.extensions.ProjectExtensionDescriptor
|
||||
*/
|
||||
public abstract class KtCompilerPluginsProvider {
|
||||
|
||||
enum class CompilerPluginType {
|
||||
public enum class CompilerPluginType {
|
||||
ASSIGNMENT
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user