Refactoring

This commit is contained in:
Valentin Kipyatkov
2016-09-16 19:38:08 +03:00
parent 7eac49be62
commit c8260f8d98
4 changed files with 18 additions and 8 deletions
@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.idea.search.usagesSearch
import com.intellij.openapi.application.ApplicationManager
import com.intellij.psi.PsiConstructorCall
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiMethod
@@ -111,8 +112,14 @@ private fun KtElement.getConstructorCallDescriptor(): DeclarationDescriptor? {
return null
}
fun PsiElement.processDelegationCallConstructorUsages(scope: SearchScope, process: (KtCallElement) -> Boolean): Boolean {
val task = buildProcessDelegationCallConstructorUsagesTask(scope, process)
return task()
}
// should be executed under read-action, returns long-running part to be executed outside read-action
fun PsiElement.buildProcessDelegationCallConstructorUsagesTask(scope: SearchScope, process: (KtCallElement) -> Boolean): () -> Boolean {
ApplicationManager.getApplication().assertReadAccessAllowed()
val task1 = buildProcessDelegationCallKotlinConstructorUsagesTask(scope, process)
val task2 = buildProcessDelegationCallJavaConstructorUsagesTask(scope, process)
return { task1() && task2() }