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,
|
* Otherwise, each test would start indexing of stdlib from scratch,
|
||||||
* and under the lock which makes tests extremely slow*/
|
* and under the lock which makes tests extremely slow*/
|
||||||
class KotlinFakeClsStubsCache {
|
public class KotlinFakeClsStubsCache {
|
||||||
private val fakeFileClsStubs = CollectionFactory.createConcurrentWeakValueMap<String, List<KotlinFileStubImpl>>()
|
private val fakeFileClsStubs = CollectionFactory.createConcurrentWeakValueMap<String, List<KotlinFileStubImpl>>()
|
||||||
|
|
||||||
companion object {
|
public companion object {
|
||||||
fun processAdditionalRoot(root: VirtualFile, storage: (VirtualFile) -> List<KotlinFileStubImpl>): List<KotlinFileStubImpl>? {
|
public fun processAdditionalRoot(root: VirtualFile, storage: (VirtualFile) -> List<KotlinFileStubImpl>): List<KotlinFileStubImpl>? {
|
||||||
val service = ApplicationManager.getApplication().getService(KotlinFakeClsStubsCache::class.java) ?: return null
|
val service = ApplicationManager.getApplication().getService(KotlinFakeClsStubsCache::class.java) ?: return null
|
||||||
if (service.fakeFileClsStubs[root.path] == null) {
|
if (service.fakeFileClsStubs[root.path] == null) {
|
||||||
service.fakeFileClsStubs[root.path] = storage(root)
|
service.fakeFileClsStubs[root.path] = storage(root)
|
||||||
|
|||||||
@@ -3,10 +3,6 @@ plugins {
|
|||||||
id("jps-compatible")
|
id("jps-compatible")
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
|
||||||
explicitApiWarning()
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(intellijCore())
|
implementation(intellijCore())
|
||||||
implementation(project(":compiler:psi"))
|
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.*
|
import org.jetbrains.kotlin.analysis.test.framework.test.configurators.*
|
||||||
|
|
||||||
object AnalysisApiFirStandaloneModeTestConfiguratorFactory : AnalysisApiTestConfiguratorFactory() {
|
public object AnalysisApiFirStandaloneModeTestConfiguratorFactory : AnalysisApiTestConfiguratorFactory() {
|
||||||
override fun createConfigurator(data: AnalysisApiTestConfiguratorFactoryData): AnalysisApiTestConfigurator {
|
override fun createConfigurator(data: AnalysisApiTestConfiguratorFactoryData): AnalysisApiTestConfigurator {
|
||||||
requireSupported(data)
|
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.TestModuleStructure
|
||||||
import org.jetbrains.kotlin.test.services.TestServices
|
import org.jetbrains.kotlin.test.services.TestServices
|
||||||
|
|
||||||
object StandaloneModeConfigurator : AnalysisApiTestConfigurator() {
|
public object StandaloneModeConfigurator : AnalysisApiTestConfigurator() {
|
||||||
override val analyseInDependentSession: Boolean get() = false
|
override val analyseInDependentSession: Boolean get() = false
|
||||||
override val frontendKind: FrontendKind get() = FrontendKind.Fir
|
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.analysis.test.framework.test.configurators.AnalysisApiTestServiceRegistrar
|
||||||
import org.jetbrains.kotlin.test.services.TestServices
|
import org.jetbrains.kotlin.test.services.TestServices
|
||||||
|
|
||||||
object StandaloneModeTestServiceRegistrar : AnalysisApiTestServiceRegistrar() {
|
public object StandaloneModeTestServiceRegistrar : AnalysisApiTestServiceRegistrar() {
|
||||||
override fun registerProjectExtensionPoints(project: MockProject, testServices: TestServices) {
|
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.TestServices
|
||||||
import org.jetbrains.kotlin.test.services.assertions
|
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) {
|
override fun doTestByFileStructure(ktFiles: List<KtFile>, module: TestModule, testServices: TestServices) {
|
||||||
val mainKtFile = ktFiles.singleOrNull() ?: ktFiles.firstOrNull { it.name == "main.kt" } ?: ktFiles.first()
|
val mainKtFile = ktFiles.singleOrNull() ?: ktFiles.firstOrNull { it.name == "main.kt" } ?: ktFiles.first()
|
||||||
val caretPosition = testServices.expressionMarkerProvider.getCaretPosition(mainKtFile)
|
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.KtNamedFunction
|
||||||
import org.jetbrains.kotlin.psi.KtParameter
|
import org.jetbrains.kotlin.psi.KtParameter
|
||||||
|
|
||||||
object TestPsiElementRenderer {
|
public object TestPsiElementRenderer {
|
||||||
fun render(psiElement: PsiElement): String = when (psiElement) {
|
public fun render(psiElement: PsiElement): String = when (psiElement) {
|
||||||
is KtNamedFunction -> buildString {
|
is KtNamedFunction -> buildString {
|
||||||
append("KtNamedFunction:")
|
append("KtNamedFunction:")
|
||||||
append(psiElement.name)
|
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
|
import org.jetbrains.kotlin.analysis.api.scopes.KtScope
|
||||||
|
|
||||||
public abstract class KtSymbolFromResolveExtensionProvider : KtAnalysisSessionComponent() {
|
public abstract class KtSymbolFromResolveExtensionProvider : KtAnalysisSessionComponent() {
|
||||||
abstract fun getResolveExtensionScopeWithTopLevelDeclarations(): KtScope
|
public abstract fun getResolveExtensionScopeWithTopLevelDeclarations(): KtScope
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface KtSymbolFromResolveExtensionProviderMixIn : KtAnalysisSessionMixIn {
|
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.KtResolveExtension
|
||||||
* @see org.jetbrains.kotlin.analysis.api.resolve.extensions.KtResolveExtensionProvider
|
* @see org.jetbrains.kotlin.analysis.api.resolve.extensions.KtResolveExtensionProvider
|
||||||
*/
|
*/
|
||||||
fun getResolveExtensionScopeWithTopLevelDeclarations(): KtScope = withValidityAssertion {
|
public fun getResolveExtensionScopeWithTopLevelDeclarations(): KtScope = withValidityAssertion {
|
||||||
analysisSession.resolveExtensionProvider.getResolveExtensionScopeWithTopLevelDeclarations()
|
analysisSession.resolveExtensionProvider.getResolveExtensionScopeWithTopLevelDeclarations()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.name.FqName
|
|||||||
* @see KtResolveExtensionFile
|
* @see KtResolveExtensionFile
|
||||||
* @see KtResolveExtensionProvider
|
* @see KtResolveExtensionProvider
|
||||||
*/
|
*/
|
||||||
abstract class KtResolveExtension {
|
public abstract class KtResolveExtension {
|
||||||
/**
|
/**
|
||||||
* Get the list of files that should be generated for the module.
|
* Get the list of files that should be generated for the module.
|
||||||
*
|
*
|
||||||
@@ -32,7 +32,7 @@ abstract class KtResolveExtension {
|
|||||||
* @see KtResolveExtensionFile
|
* @see KtResolveExtensionFile
|
||||||
* @see KtResolveExtension
|
* @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].
|
* Returns a [ModificationTracker], which controls the validity lifecycle of the files provided by [getKtFiles].
|
||||||
@@ -42,7 +42,7 @@ abstract class KtResolveExtension {
|
|||||||
*
|
*
|
||||||
* @see 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].
|
* Returns the set of packages that are contained in the files provided by [getKtFiles].
|
||||||
@@ -52,5 +52,5 @@ abstract class KtResolveExtension {
|
|||||||
*
|
*
|
||||||
* @see 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
|
* @see KtResolveExtension
|
||||||
*/
|
*/
|
||||||
abstract class KtResolveExtensionFile {
|
public abstract class KtResolveExtensionFile {
|
||||||
/**
|
/**
|
||||||
* The name a Kotlin file which will be generated.
|
* The name a Kotlin file which will be generated.
|
||||||
*
|
*
|
||||||
@@ -28,7 +28,7 @@ abstract class KtResolveExtensionFile {
|
|||||||
*
|
*
|
||||||
* @see KtResolveExtensionFile
|
* @see KtResolveExtensionFile
|
||||||
*/
|
*/
|
||||||
abstract fun getFileName(): String
|
public abstract fun getFileName(): String
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [FqName] of the package specified in the file
|
* [FqName] of the package specified in the file
|
||||||
@@ -39,7 +39,7 @@ abstract class KtResolveExtensionFile {
|
|||||||
*
|
*
|
||||||
* @see 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.
|
* 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
|
* @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.
|
* Returns the set of top-level callable (functions and properties) names in the file.
|
||||||
@@ -57,7 +57,7 @@ abstract class KtResolveExtensionFile {
|
|||||||
*
|
*
|
||||||
* @see KtResolveExtensionFile
|
* @see KtResolveExtensionFile
|
||||||
*/
|
*/
|
||||||
abstract fun getTopLevelCallableNames(): Set<Name>
|
public abstract fun getTopLevelCallableNames(): Set<Name>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the generated Kotlin source file text.
|
* Creates the generated Kotlin source file text.
|
||||||
@@ -74,7 +74,7 @@ abstract class KtResolveExtensionFile {
|
|||||||
*
|
*
|
||||||
* @see KtResolveExtensionFile
|
* @see KtResolveExtensionFile
|
||||||
*/
|
*/
|
||||||
abstract fun buildFileText(): String
|
public abstract fun buildFileText(): String
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a [KtResolveExtensionReferencePsiTargetsProvider] for this [KtResolveExtensionFile].
|
* Creates a [KtResolveExtensionReferencePsiTargetsProvider] for this [KtResolveExtensionFile].
|
||||||
@@ -82,6 +82,5 @@ abstract class KtResolveExtensionFile {
|
|||||||
* @see KtResolveExtensionReferencePsiTargetsProvider
|
* @see KtResolveExtensionReferencePsiTargetsProvider
|
||||||
* @see KtResolveExtensionFile
|
* @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.
|
* 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].
|
* 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.
|
* 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 {
|
public companion object {
|
||||||
val EP_NAME = ExtensionPointName<KtResolveExtensionProvider>("org.jetbrains.kotlin.ktResolveExtensionProvider")
|
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) }
|
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.KtAnalysisSession
|
||||||
import org.jetbrains.kotlin.analysis.api.symbols.KtSymbol
|
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]
|
* 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.
|
* 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 {
|
public abstract class KtCompilerPluginsProvider {
|
||||||
|
|
||||||
enum class CompilerPluginType {
|
public enum class CompilerPluginType {
|
||||||
ASSIGNMENT
|
ASSIGNMENT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user