processAllExactUsages() only for KtDeclaration
This commit is contained in:
@@ -34,18 +34,19 @@ import org.jetbrains.kotlin.psi.KtConstructor
|
|||||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||||
import org.jetbrains.kotlin.psi.KtPsiUtil
|
import org.jetbrains.kotlin.psi.KtPsiUtil
|
||||||
import org.jetbrains.kotlin.utils.SmartList
|
import org.jetbrains.kotlin.utils.SmartList
|
||||||
|
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||||
|
|
||||||
fun PsiElement.processAllExactUsages(
|
fun KtDeclaration.processAllExactUsages(
|
||||||
options: FindUsagesOptions,
|
options: FindUsagesOptions,
|
||||||
processor: (UsageInfo) -> Unit
|
processor: (UsageInfo) -> Unit
|
||||||
) {
|
) {
|
||||||
fun elementsToCheckReferenceAgainst(reference: PsiReference): List<PsiElement> {
|
fun elementsToCheckReferenceAgainst(reference: PsiReference): List<PsiElement> {
|
||||||
if (reference is KtReference || this !is KtDeclaration) return listOf(this)
|
if (reference is KtReference) return listOf(this)
|
||||||
return SmartList<PsiElement>().also { list ->
|
return SmartList<PsiElement>().also { list ->
|
||||||
list += this
|
list += this
|
||||||
list += toLightElements()
|
list += toLightElements()
|
||||||
if (this is KtConstructor<*>) {
|
if (this is KtConstructor<*>) {
|
||||||
getContainingClassOrObject().toLightClass()?.let { list += it }
|
list.addIfNotNull(getContainingClassOrObject().toLightClass())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user