[kotlin fir] fix creating symbol not in analysis scope
^KTIJ-21504 fixed
This commit is contained in:
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.analysis.api.symbols.KtSymbolProvider
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtSymbolProviderMixIn
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.pointers.KtSymbolPointer
|
||||
import org.jetbrains.kotlin.analysis.api.tokens.ValidityToken
|
||||
import org.jetbrains.kotlin.analysis.project.structure.KtModule
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
|
||||
@@ -53,7 +54,10 @@ public abstract class KtAnalysisSession(final override val token: ValidityToken)
|
||||
KtVisibilityCheckerMixIn,
|
||||
KtMemberSymbolProviderMixin,
|
||||
KtInheritorsProviderMixIn,
|
||||
KtTypeCreatorMixIn {
|
||||
KtTypeCreatorMixIn,
|
||||
KtAnalysisScopeProviderMixIn {
|
||||
|
||||
public abstract val useSiteModule: KtModule
|
||||
|
||||
override val analysisSession: KtAnalysisSession get() = this
|
||||
|
||||
@@ -131,6 +135,9 @@ public abstract class KtAnalysisSession(final override val token: ValidityToken)
|
||||
internal val symbolInfoProvider: KtSymbolInfoProvider get() = symbolInfoProviderImpl
|
||||
protected abstract val symbolInfoProviderImpl: KtSymbolInfoProvider
|
||||
|
||||
internal val analysisScopeProvider: KtAnalysisScopeProvider get() = analysisScopeProviderImpl
|
||||
protected abstract val analysisScopeProviderImpl: KtAnalysisScopeProvider
|
||||
|
||||
@PublishedApi
|
||||
internal val typesCreator: KtTypeCreator
|
||||
get() = typesCreatorImpl
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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 com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||
|
||||
public abstract class KtAnalysisScopeProvider : KtAnalysisSessionComponent() {
|
||||
public abstract fun getAnalysisScope(): GlobalSearchScope
|
||||
|
||||
public abstract fun canBeAnalysed(psi: PsiElement): Boolean
|
||||
}
|
||||
|
||||
public interface KtAnalysisScopeProviderMixIn : KtAnalysisSessionMixIn {
|
||||
/**
|
||||
* Return [GlobalSearchScope] represent a scope code in which can be analysed by current [KtAnalysisSession].
|
||||
* That means [org.jetbrains.kotlin.analysis.api.symbols.KtSymbol] can be built for the declarations from this scope.
|
||||
*/
|
||||
public val analysisScope: GlobalSearchScope
|
||||
get() = analysisSession.analysisScopeProvider.getAnalysisScope()
|
||||
|
||||
|
||||
/**
|
||||
* Checks if [PsiElement] is inside analysis scope.
|
||||
* That means [org.jetbrains.kotlin.analysis.api.symbols.KtSymbol] can be built by this [PsiElement]
|
||||
*
|
||||
* @see analysisScope
|
||||
*/
|
||||
public fun PsiElement.canBeAnalysed(): Boolean =
|
||||
analysisSession.analysisScopeProvider.canBeAnalysed(this)
|
||||
}
|
||||
Reference in New Issue
Block a user