Disabled smart search for classes from library
This commit is contained in:
+8
-2
@@ -41,6 +41,7 @@ import org.jetbrains.kotlin.idea.search.ideaExtensions.KotlinRequestResultProces
|
||||
import org.jetbrains.kotlin.idea.search.restrictToKotlinSources
|
||||
import org.jetbrains.kotlin.idea.search.usagesSearch.DestructuringDeclarationUsageSearch.*
|
||||
import org.jetbrains.kotlin.idea.util.FuzzyType
|
||||
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
|
||||
import org.jetbrains.kotlin.idea.util.fuzzyExtensionReceiverType
|
||||
import org.jetbrains.kotlin.idea.util.toFuzzyType
|
||||
import org.jetbrains.kotlin.kdoc.psi.impl.KDocName
|
||||
@@ -59,7 +60,6 @@ enum class DestructuringDeclarationUsageSearch {
|
||||
|
||||
var destructuringDeclarationUsageSearchMode = if (ApplicationManager.getApplication().isUnitTestMode) ALWAYS_SMART else PLAIN_WHEN_NEEDED
|
||||
|
||||
//TODO: compiled code
|
||||
//TODO: check if it's too expensive
|
||||
|
||||
fun findDestructuringDeclarationUsages(
|
||||
@@ -127,7 +127,7 @@ private class Processor(
|
||||
|
||||
// we don't need to search usages of declarations in Java because Java doesn't have implicitly typed declarations so such usages cannot affect Kotlin code
|
||||
//TODO: what about Scala and other JVM-languages?
|
||||
private val declarationUsageScope = GlobalSearchScope.projectScope(project).restrictToKotlinSources() //TODO: search in libraries?
|
||||
private val declarationUsageScope = GlobalSearchScope.projectScope(project).restrictToKotlinSources()
|
||||
|
||||
private val declarationsToProcess = ArrayDeque<PsiElement>()
|
||||
private val declarationsToProcessSet = HashSet<PsiElement>()
|
||||
@@ -142,6 +142,12 @@ private class Processor(
|
||||
else -> return
|
||||
}
|
||||
|
||||
// for data class from library always use plain search because we cannot search usages in compiled code (we could though)
|
||||
if (!ProjectRootsUtil.isInProjectSource(psiClass)) {
|
||||
plainSearchHandler(searchScope)
|
||||
return
|
||||
}
|
||||
|
||||
val parameters = ClassInheritorsSearch.SearchParameters(psiClass, GlobalSearchScope.allScope(project), true, true, false)
|
||||
val classesToSearch = listOf(psiClass) + ClassInheritorsSearch.search(parameters).findAll()
|
||||
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtFunction
|
||||
// OPTIONS: usages
|
||||
// FIND_BY_REF
|
||||
|
||||
fun foo(p: Pair<Int, Int>) {
|
||||
p.<caret>component1()
|
||||
val (x, y) = p
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
val (x, y) = 1 to "a"
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
Function call 6 p.component1()
|
||||
Value read 11 val (x, y) = 1 to "a"
|
||||
Value read 7 val (x, y) = p
|
||||
@@ -194,6 +194,12 @@ public class FindUsagesTestGenerated extends AbstractFindUsagesTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("dataClassFromStdlib.0.kt")
|
||||
public void testDataClassFromStdlib() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/findUsages/kotlin/conventions/components/dataClassFromStdlib.0.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("extensionComponentFun.0.kt")
|
||||
public void testExtensionComponentFun() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/findUsages/kotlin/conventions/components/extensionComponentFun.0.kt");
|
||||
|
||||
Reference in New Issue
Block a user