[light classes] rewrite findEntry to avoid resolve and move to light-classes-base module

^KT-53097
This commit is contained in:
Dmitry Gridin
2022-07-11 21:54:31 +02:00
committed by Space
parent 2ff1c21c8c
commit 05528a051b
2 changed files with 20 additions and 21 deletions
@@ -1,21 +0,0 @@
/*
* 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.asJava.classes
import org.jetbrains.kotlin.asJava.LightClassGenerationSupport
import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.psi.KtSuperTypeList
import org.jetbrains.kotlin.psi.KtSuperTypeListEntry
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
fun KtSuperTypeList.findEntry(fqNameToFind: String): KtSuperTypeListEntry? {
val context = LightClassGenerationSupport.getInstance(project).analyzeWithContent(parent as KtClassOrObject)
return entries.firstOrNull {
val referencedType = context[BindingContext.TYPE, it.typeReference]
referencedType?.constructor?.declarationDescriptor?.fqNameUnsafe?.asString() == fqNameToFind
}
}