From 8e319041fc7dfd390b31b027c5e5e986049fec25 Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 20 Aug 2015 17:27:08 +0200 Subject: [PATCH] better AST and smart pointer gc-ability during find usages (https://youtrack.jetbrains.com/issue/IDEA-144136#comment=27-1096458) --- .../intellij/usages/impl/UsageViewImpl.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java b/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java index a6da1b610072..5d3aa9da061d 100644 --- a/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java +++ b/platform/usageView/src/com/intellij/usages/impl/UsageViewImpl.java @@ -43,6 +43,7 @@ import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.pom.Navigatable; import com.intellij.psi.PsiDocumentManager; +import com.intellij.psi.PsiManager; import com.intellij.psi.SmartPointerManager; import com.intellij.psi.SmartPsiElementPointer; import com.intellij.psi.impl.PsiDocumentManagerBase; @@ -867,9 +868,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra setSearchInProgress(true); associateProgress(indicator); - myChangesDetected = false; - UsageSearcher usageSearcher = myUsageSearcherFactory.create(); - usageSearcher.generate(new Processor() { + Processor processor = new Processor() { @Override public boolean process(final Usage usage) { if (searchHasBeenCancelled()) return false; @@ -882,7 +881,8 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra if (usageCount > UsageLimitUtil.USAGES_LIMIT) { if (tooManyUsagesStatus.switchTooManyUsagesStatus()) { UsageViewManagerImpl - .showTooManyUsagesWarning(project, tooManyUsagesStatus, indicator, getPresentation(), usageCountWithoutDefinition.get(), UsageViewImpl.this); + .showTooManyUsagesWarning(project, tooManyUsagesStatus, indicator, getPresentation(), usageCountWithoutDefinition.get(), + UsageViewImpl.this); } } ApplicationManager.getApplication().runReadAction(new Runnable() { @@ -894,8 +894,17 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra } return !indicator.isCanceled(); } - }); - drainQueuedUsageNodes(); + }; + + myChangesDetected = false; + PsiManager.getInstance(project).startBatchFilesProcessingMode(); + try { + myUsageSearcherFactory.create().generate(processor); + drainQueuedUsageNodes(); + } + finally { + PsiManager.getInstance(project).finishBatchFilesProcessingMode(); + } setSearchInProgress(false); } };