diff --git a/platform/find/backend/src/FindRemoteApiImpl.kt b/platform/find/backend/src/FindRemoteApiImpl.kt index 458dd0e2c98b..ff90e26a1c80 100644 --- a/platform/find/backend/src/FindRemoteApiImpl.kt +++ b/platform/find/backend/src/FindRemoteApiImpl.kt @@ -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, maxUsagesCount: Int): Flow { 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 diff --git a/platform/find/src/UsageInfoModelPresentationProvider.kt b/platform/find/src/UsageInfoModelPresentationProvider.kt index a292e2f75ef3..ac17b4c3ea25 100644 --- a/platform/find/src/UsageInfoModelPresentationProvider.kt +++ b/platform/find/src/UsageInfoModelPresentationProvider.kt @@ -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(), diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java b/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java index 78d7a66ab80a..3663db993d96 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java +++ b/platform/lang-impl/src/com/intellij/find/impl/FindPopupPanel.java @@ -1221,10 +1221,10 @@ public final class FindPopupPanel extends JBPanel 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> recentItemRef = new ThreadLocal<>(); Set filePaths = ConcurrentHashMap.newKeySet(); diff --git a/platform/lang-impl/src/com/intellij/find/impl/UsagePresentationProvider.kt b/platform/lang-impl/src/com/intellij/find/impl/UsagePresentationProvider.kt index 665985df9158..79129f4c86ab 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/UsagePresentationProvider.kt +++ b/platform/lang-impl/src/com/intellij/find/impl/UsagePresentationProvider.kt @@ -13,9 +13,9 @@ interface UsagePresentationProvider { private val EP_NAME = ExtensionPointName("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? } \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/find/impl/uiModel.kt b/platform/lang-impl/src/com/intellij/find/impl/uiModel.kt index 8d5c0b693234..db18a032b92c 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/uiModel.kt +++ b/platform/lang-impl/src/com/intellij/find/impl/uiModel.kt @@ -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) } }