Not trying to find declaration in both builtins and decompiled code (as it worked before).
This commit is contained in:
@@ -52,3 +52,5 @@ public inline fun <reified T> Array<*>.firstIsInstance(): T {
|
||||
for (element in this) if (element is T) return element
|
||||
throw NoSuchElementException("No element of given type found")
|
||||
}
|
||||
|
||||
public fun <T> streamOfLazyValues(vararg elements: () -> T): Stream<T> = elements.stream().map { it() }
|
||||
+7
-5
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.*
|
||||
import java.util.*
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.streamOfLazyValues
|
||||
|
||||
public object DescriptorToSourceUtilsIde {
|
||||
// Returns PSI element for descriptor. If there are many relevant elements (e.g. it is fake override
|
||||
@@ -46,11 +47,12 @@ public object DescriptorToSourceUtilsIde {
|
||||
|
||||
private fun getDeclarationsStream(project: Project, targetDescriptor: DeclarationDescriptor): Stream<PsiElement> {
|
||||
val effectiveReferencedDescriptors = DescriptorToSourceUtils.getEffectiveReferencedDescriptors(targetDescriptor).stream()
|
||||
return effectiveReferencedDescriptors.flatMap {
|
||||
streamOf(
|
||||
DescriptorToSourceUtils.getSourceFromDescriptor(it),
|
||||
findBuiltinDeclaration(project, it),
|
||||
DecompiledNavigationUtils.getDeclarationFromDecompiledClassFile(project, it)
|
||||
return effectiveReferencedDescriptors.flatMap { effectiveReferenced ->
|
||||
// References in library sources should be resolved to corresponding decompiled declarations,
|
||||
// therefore we put both source declaration and decompiled declaration to stream, and afterwards we filter it in getAllDeclarations
|
||||
streamOfLazyValues(
|
||||
{ DescriptorToSourceUtils.getSourceFromDescriptor(effectiveReferenced) },
|
||||
{ findBuiltinDeclaration(project, effectiveReferenced) ?: DecompiledNavigationUtils.getDeclarationFromDecompiledClassFile(project, effectiveReferenced) }
|
||||
)
|
||||
}.filterNotNull()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user