Light Classes: Fix origin search for KtLightSuperTypeReference
Use analyzeFully() when resolving super type references
This commit is contained in:
+2
@@ -153,6 +153,8 @@ class CliLightClassGenerationSupport(project: Project) : LightClassGenerationSup
|
||||
|
||||
override fun analyze(element: KtElement) = bindingContext
|
||||
|
||||
override fun analyzeFully(element: KtElement) = bindingContext
|
||||
|
||||
override fun getFacadeClasses(facadeFqName: FqName, scope: GlobalSearchScope): Collection<PsiClass> {
|
||||
val filesForFacade = findFilesForFacade(facadeFqName, scope)
|
||||
if (filesForFacade.isEmpty()) return emptyList()
|
||||
|
||||
@@ -65,6 +65,8 @@ abstract class LightClassGenerationSupport {
|
||||
|
||||
abstract fun analyze(element: KtElement): BindingContext
|
||||
|
||||
abstract fun analyzeFully(element: KtElement): BindingContext
|
||||
|
||||
abstract fun getFacadeClasses(facadeFqName: FqName, scope: GlobalSearchScope): Collection<PsiClass>
|
||||
|
||||
abstract fun getMultifilePartClasses(partFqName: FqName, scope: GlobalSearchScope): Collection<PsiClass>
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ class KtLightPsiReferenceList (
|
||||
override val kotlinOrigin by lazyPub {
|
||||
val superTypeList = this@KtLightPsiReferenceList.kotlinOrigin ?: return@lazyPub null
|
||||
val fqNameToFind = clsDelegate.qualifiedName ?: return@lazyPub null
|
||||
val context = LightClassGenerationSupport.getInstance(project).analyze(superTypeList)
|
||||
val context = LightClassGenerationSupport.getInstance(project).analyzeFully(superTypeList)
|
||||
superTypeList.entries.firstOrNull {
|
||||
val referencedType = context[BindingContext.TYPE, it.typeReference]
|
||||
referencedType?.constructor?.declarationDescriptor?.fqNameUnsafe?.asString() == fqNameToFind
|
||||
|
||||
+3
@@ -50,6 +50,7 @@ import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
|
||||
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import org.jetbrains.kotlin.resolve.lazy.NoDescriptorForDeclarationException
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
@@ -209,6 +210,8 @@ class IDELightClassGenerationSupport(private val project: Project) : LightClassG
|
||||
|
||||
override fun analyze(element: KtElement) = element.analyze(BodyResolveMode.PARTIAL)
|
||||
|
||||
override fun analyzeFully(element: KtElement) = element.analyzeFully()
|
||||
|
||||
override fun getFacadeNames(packageFqName: FqName, scope: GlobalSearchScope): Collection<String> {
|
||||
val facadeFilesInPackage = KotlinFileFacadeClassByPackageIndex.getInstance().get(packageFqName.asString(), project, scope)
|
||||
return facadeFilesInPackage.map { it.javaFileFacadeFqName.shortName().asString() }
|
||||
|
||||
Reference in New Issue
Block a user