DecompiledNavigationUtils -> findDecompiledDeclaration()

This commit is contained in:
Pavel V. Talanov
2015-12-10 12:23:31 +03:00
parent d89b609960
commit 01b79f640f
2 changed files with 90 additions and 99 deletions
@@ -18,16 +18,10 @@ package org.jetbrains.kotlin.idea.codeInsight
import com.intellij.openapi.project.Project import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.idea.decompiler.navigation.findDecompiledDeclaration
import org.jetbrains.kotlin.idea.decompiler.navigation.DecompiledNavigationUtils
import org.jetbrains.kotlin.idea.references.BuiltInsReferenceResolver import org.jetbrains.kotlin.idea.references.BuiltInsReferenceResolver
import com.intellij.psi.JavaPsiFacade import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
import org.jetbrains.kotlin.idea.search.allScope
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.sequenceOfLazyValues import org.jetbrains.kotlin.utils.addToStdlib.sequenceOfLazyValues
public object DescriptorToSourceUtilsIde { public object DescriptorToSourceUtilsIde {
@@ -52,7 +46,7 @@ public object DescriptorToSourceUtilsIde {
// therefore we put both source declaration and decompiled declaration to stream, and afterwards we filter it in getAllDeclarations // therefore we put both source declaration and decompiled declaration to stream, and afterwards we filter it in getAllDeclarations
sequenceOfLazyValues( sequenceOfLazyValues(
{ DescriptorToSourceUtils.getSourceFromDescriptor(effectiveReferenced) }, { DescriptorToSourceUtils.getSourceFromDescriptor(effectiveReferenced) },
{ BuiltInsReferenceResolver.resolveBuiltInSymbol(project, effectiveReferenced) ?: DecompiledNavigationUtils.getDeclarationFromDecompiledClassFile(project, effectiveReferenced) } { BuiltInsReferenceResolver.resolveBuiltInSymbol(project, effectiveReferenced) ?: findDecompiledDeclaration(project, effectiveReferenced) }
) )
}.filterNotNull() }.filterNotNull()
} }
@@ -39,9 +39,7 @@ import org.jetbrains.kotlin.serialization.js.KotlinJavascriptPackageFragment
import org.jetbrains.kotlin.types.ErrorUtils import org.jetbrains.kotlin.types.ErrorUtils
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils
object DecompiledNavigationUtils { fun findDecompiledDeclaration(
fun getDeclarationFromDecompiledClassFile(
project: Project, project: Project,
referencedDescriptor: DeclarationDescriptor): KtDeclaration? { referencedDescriptor: DeclarationDescriptor): KtDeclaration? {
if (isLocal(referencedDescriptor)) return null if (isLocal(referencedDescriptor)) return null
@@ -132,4 +130,3 @@ object DecompiledNavigationUtils {
} }
return null return null
} }
}