Do not stop searchTextOccurrences when isSearchForTextOccurrences is false

#KT-36657 Fixed
This commit is contained in:
kovalp
2020-02-12 16:46:03 +01:00
committed by Vladimir Dolzhenko
parent 6fd8ccc293
commit 9ceca69154
2 changed files with 34 additions and 1 deletions
@@ -55,7 +55,7 @@ abstract class KotlinFindUsagesHandler<T : PsiElement>(
}
private fun searchTextOccurrences(element: PsiElement, processor: UsageInfoProcessor, options: FindUsagesOptions): Boolean {
if (!options.isSearchForTextOccurrences) return false
if (!options.isSearchForTextOccurrences) return true
val scope = options.searchScope
@@ -0,0 +1,33 @@
/*
* Copyright 2010-2020 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.findUsages
import com.intellij.find.findUsages.CustomUsageSearcher
import com.intellij.find.findUsages.FindUsagesOptions
import com.intellij.openapi.application.runReadAction
import com.intellij.psi.PsiElement
import com.intellij.testFramework.ExtensionTestUtil
import com.intellij.usageView.UsageInfo
import com.intellij.usages.Usage
import com.intellij.usages.UsageInfo2UsageAdapter
import com.intellij.util.Processor
import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCaseBase
class CustomUsageSearcherTest : KotlinLightCodeInsightFixtureTestCaseBase() {
fun testAddCustomUsagesForKotlin() {
val customUsageSearcher = object : CustomUsageSearcher() {
override fun processElementUsages(element: PsiElement, processor: Processor<Usage>, options: FindUsagesOptions) {
runReadAction { processor.process(UsageInfo2UsageAdapter(UsageInfo(element))) }
}
}
ExtensionTestUtil.maskExtensions(CustomUsageSearcher.EP_NAME, listOf(customUsageSearcher), testRootDisposable)
myFixture.configureByText(KotlinFileType.INSTANCE, """val <caret>selfUsed = 1""")
val usages = myFixture.getUsageViewTreeTextRepresentation(myFixture.elementAtCaret)
assertTrue(usages.contains("val selfUsed"))
}
}