Analysis API: add KtReference..Provider to fix reference resolve in FE10

This commit is contained in:
Mikhail Glukhikh
2022-05-30 12:17:08 +02:00
committed by Space
parent d67e910ee8
commit 8cb3081bbd
7 changed files with 70 additions and 4 deletions
@@ -139,6 +139,9 @@ public abstract class KtAnalysisSession(final override val token: KtLifetimeToke
internal val analysisScopeProvider: KtAnalysisScopeProvider get() = analysisScopeProviderImpl
protected abstract val analysisScopeProviderImpl: KtAnalysisScopeProvider
internal val referenceResolveProvider: KtReferenceResolveProvider get() = referenceResolveProviderImpl
protected abstract val referenceResolveProviderImpl: KtReferenceResolveProvider
@PublishedApi
internal val typesCreator: KtTypeCreator
get() = typesCreatorImpl
@@ -5,18 +5,15 @@
package org.jetbrains.kotlin.analysis.api.components
import org.jetbrains.kotlin.analysis.api.KtSymbolBasedReference
import org.jetbrains.kotlin.analysis.api.symbols.KtSymbol
import org.jetbrains.kotlin.idea.references.KtReference
public interface KtReferenceResolveMixIn : KtAnalysisSessionMixIn {
public fun KtReference.resolveToSymbols(): Collection<KtSymbol> {
check(this is KtSymbolBasedReference) { "To get reference symbol the one should be KtSymbolBasedReference" }
return analysisSession.resolveToSymbols()
return analysisSession.referenceResolveProvider.resolveToSymbols(this)
}
public fun KtReference.resolveToSymbol(): KtSymbol? {
check(this is KtSymbolBasedReference) { "To get reference symbol the one should be KtSymbolBasedReference but was ${this::class}" }
return resolveToSymbols().singleOrNull()
}
}
@@ -0,0 +1,13 @@
/*
* Copyright 2010-2022 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.api.components
import org.jetbrains.kotlin.analysis.api.symbols.KtSymbol
import org.jetbrains.kotlin.idea.references.KtReference
public abstract class KtReferenceResolveProvider {
public abstract fun resolveToSymbols(reference: KtReference): Collection<KtSymbol>
}