Added progress when searching invoke() by plain search
This commit is contained in:
+27
-6
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.search.usagesSearch
|
package org.jetbrains.kotlin.idea.search.usagesSearch
|
||||||
|
|
||||||
|
import com.intellij.openapi.progress.ProgressIndicatorProvider
|
||||||
|
import com.intellij.openapi.progress.util.ProgressWrapper
|
||||||
import com.intellij.openapi.roots.ProjectRootManager
|
import com.intellij.openapi.roots.ProjectRootManager
|
||||||
import com.intellij.psi.*
|
import com.intellij.psi.*
|
||||||
import com.intellij.psi.search.*
|
import com.intellij.psi.search.*
|
||||||
@@ -43,6 +45,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.isExtension
|
|||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
import org.jetbrains.kotlin.util.isValidOperator
|
import org.jetbrains.kotlin.util.isValidOperator
|
||||||
|
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.check
|
import org.jetbrains.kotlin.utils.addToStdlib.check
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@@ -255,14 +258,32 @@ abstract class OperatorReferenceSearcher<TReferenceElement : KtElement>(
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
val psiManager = PsiManager.getInstance(project)
|
val psiManager = PsiManager.getInstance(project)
|
||||||
ProjectRootManager.getInstance(project).fileIndex.iterateContent { file ->
|
// we must unwrap progress indicator because ProgressWrapper does not do anything on changing text and fraction
|
||||||
if (file in scope) {
|
val progress = ProgressWrapper.unwrap(ProgressIndicatorProvider.getGlobalProgressIndicator())
|
||||||
val ktFile = runReadAction { psiManager.findFile(file) as? KtFile }
|
progress?.pushState()
|
||||||
if (ktFile != null) {
|
progress?.text = "Searching implicit usages..."
|
||||||
doPlainSearch(LocalSearchScope(ktFile))
|
|
||||||
|
try {
|
||||||
|
val files = ArrayList<KtFile>()
|
||||||
|
ProjectRootManager.getInstance(project).fileIndex.iterateContent { file ->
|
||||||
|
progress?.checkCanceled()
|
||||||
|
runReadAction {
|
||||||
|
if (file in scope) {
|
||||||
|
files.addIfNotNull(psiManager.findFile(file) as? KtFile)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
true
|
||||||
}
|
}
|
||||||
true
|
|
||||||
|
for ((index, file) in files.withIndex()) {
|
||||||
|
progress?.checkCanceled()
|
||||||
|
progress?.fraction = index / files.size.toDouble()
|
||||||
|
progress?.text2 = file.virtualFile.path
|
||||||
|
doPlainSearch(LocalSearchScope(file))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
progress?.popState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user