mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[find in files] IJPL-198849 Remove unnecessary progressIndicator in findUsages and redundant read action in FindPopup
GitOrigin-RevId: fed7440e54461b482324eda01a5207be3b988046
This commit is contained in:
committed by
intellij-monorepo-bot
parent
c86bf79649
commit
cc15c88526
@@ -18,7 +18,6 @@ import com.intellij.ide.vfs.virtualFile
|
||||
import com.intellij.openapi.application.readAction
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.openapi.progress.EmptyProgressIndicator
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.vfs.newvfs.VfsPresentationUtil
|
||||
import com.intellij.platform.find.FindInFilesResult
|
||||
@@ -41,8 +40,7 @@ internal class FindRemoteApiImpl : FindRemoteApi {
|
||||
override suspend fun findByModel(findModel: FindModel, projectId: ProjectId, filesToScanInitially: List<VirtualFileId>, maxUsagesCount: Int): Flow<FindInFilesResult> {
|
||||
val sentItems = AtomicInteger(0)
|
||||
return channelFlow {
|
||||
//TODO rewrite find function without using progress indicator and presentation
|
||||
val progressIndicator = EmptyProgressIndicator()
|
||||
//TODO rewrite find function without using presentation
|
||||
val presentation = FindUsagesProcessPresentation(UsageViewPresentation())
|
||||
|
||||
val isReplaceState = findModel.isReplaceState
|
||||
@@ -59,7 +57,7 @@ internal class FindRemoteApiImpl : FindRemoteApi {
|
||||
setCustomScopeById(project, findModel)
|
||||
//read action is necessary in case of the loading from a directory
|
||||
val scope = readAction { FindInProjectUtil.getGlobalSearchScope(project, findModel) }
|
||||
FindInProjectUtil.findUsages(findModel, project, progressIndicator, presentation, filesToScanInitially) { usageInfo ->
|
||||
FindInProjectUtil.findUsages(findModel, project, presentation, filesToScanInitially) { usageInfo ->
|
||||
val usageNum = usagesCount.incrementAndGet()
|
||||
if (usageNum > maxUsagesCount) {
|
||||
return@findUsages false
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.usages.UsageInfoAdapter
|
||||
|
||||
private class UsageInfoModelPresentationProvider: UsagePresentationProvider {
|
||||
override fun getUsagePresentation(usageInfo: UsageInfoAdapter, project: Project, scope: GlobalSearchScope): UsagePresentation? {
|
||||
override fun getUsagePresentation(usageInfo: UsageInfoAdapter, project: Project, scope: GlobalSearchScope?): UsagePresentation? {
|
||||
if (usageInfo !is UsageInfoModel) return null
|
||||
val model = usageInfo.model
|
||||
return UsagePresentation(model.presentation.map { it.textChunk() }.toTypedArray(),
|
||||
|
||||
@@ -1221,10 +1221,10 @@ public final class FindPopupPanel extends JBPanel<FindPopupPanel> implements Fin
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
startTime.set(System.currentTimeMillis());
|
||||
AtomicLong timeToFirstResult = new AtomicLong(-1);
|
||||
GlobalSearchScope scope = ReadAction.nonBlocking(
|
||||
() -> FindInProjectUtil.getGlobalSearchScope(project, myHelper.myPreviousModel)
|
||||
).wrapProgress(indicator).executeSynchronously();
|
||||
|
||||
GlobalSearchScope scope = FindKey.isEnabled()
|
||||
? null
|
||||
: ReadAction.nonBlocking(() -> FindInProjectUtil.getGlobalSearchScope(project, myHelper.myPreviousModel))
|
||||
.wrapProgress(indicator).executeSynchronously();
|
||||
FindUsagesProcessPresentation processPresentation = FindInProjectUtil.setupProcessPresentation(myUsageViewPresentation);
|
||||
ThreadLocal<Reference<FindPopupItem>> recentItemRef = new ThreadLocal<>();
|
||||
Set<String> filePaths = ConcurrentHashMap.newKeySet();
|
||||
|
||||
@@ -13,9 +13,9 @@ interface UsagePresentationProvider {
|
||||
private val EP_NAME = ExtensionPointName<UsagePresentationProvider>("com.intellij.usagePresentationProvider")
|
||||
|
||||
@JvmStatic
|
||||
fun getPresentation(usageInfo: UsageInfoAdapter, project: Project, scope: GlobalSearchScope): UsagePresentation? {
|
||||
fun getPresentation(usageInfo: UsageInfoAdapter, project: Project, scope: GlobalSearchScope?): UsagePresentation? {
|
||||
return EP_NAME.computeSafeIfAny { extension -> extension.getUsagePresentation(usageInfo, project, scope)}
|
||||
}
|
||||
}
|
||||
fun getUsagePresentation(usageInfo: UsageInfoAdapter, project: Project, scope: GlobalSearchScope): UsagePresentation?
|
||||
fun getUsagePresentation(usageInfo: UsageInfoAdapter, project: Project, scope: GlobalSearchScope?): UsagePresentation?
|
||||
}
|
||||
@@ -84,8 +84,8 @@ internal fun usagePresentation(
|
||||
}
|
||||
|
||||
internal class UsageInfo2UsageAdapterPresentationProvider : UsagePresentationProvider {
|
||||
override fun getUsagePresentation(usageInfo: UsageInfoAdapter, project: Project, scope: GlobalSearchScope): UsagePresentation? {
|
||||
if (usageInfo !is UsageInfo2UsageAdapter) return null
|
||||
override fun getUsagePresentation(usageInfo: UsageInfoAdapter, project: Project, scope: GlobalSearchScope?): UsagePresentation? {
|
||||
if (usageInfo !is UsageInfo2UsageAdapter || scope == null) return null
|
||||
return usagePresentation(project, scope, usageInfo)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user