diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexProjectHandler.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexProjectHandler.java index 22ec3ae84d71..de8f17bd4ee5 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexProjectHandler.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexProjectHandler.java @@ -76,8 +76,9 @@ public final class FileBasedIndexProjectHandler { indicator.setIndeterminate(false); indicator.setText(IndexingBundle.message("progress.indexing.updating")); + String indexingReason = "On refresh of files in " + myProject.getName(); ProjectIndexingHistoryImpl projectIndexingHistory = new ProjectIndexingHistoryImpl(myProject, - "On refresh of files in " + myProject.getName(), + indexingReason, ScanningType.REFRESH); IndexDiagnosticDumper.getInstance().onIndexingStarted(projectIndexingHistory); @@ -109,7 +110,7 @@ public final class FileBasedIndexProjectHandler { // // Fair amount of FileBasedIndexProjectHandler.scheduleReindexingInDumbMode invocations are observed during massive refresh (e.g. branch change). // In practice, we observe 2-3 scanning tasks followed by a single indexing task. - new UnindexedFilesIndexer(myProject, files).indexFiles(projectIndexingHistory, indicator); + new UnindexedFilesIndexer(myProject, files, indexingReason).indexFiles(projectIndexingHistory, indicator); } catch (Exception e) { projectIndexingHistory.setWasInterrupted(true); diff --git a/platform/lang-impl/src/com/intellij/util/indexing/PerProjectIndexingQueue.kt b/platform/lang-impl/src/com/intellij/util/indexing/PerProjectIndexingQueue.kt index 295f95a95597..b1a72edb0160 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/PerProjectIndexingQueue.kt +++ b/platform/lang-impl/src/com/intellij/util/indexing/PerProjectIndexingQueue.kt @@ -201,11 +201,11 @@ class PerProjectIndexingQueue(private val project: Project) : Disposable { } } - fun flushNow() { + fun flushNow(reason: String) { val (filesInQueue, totalFiles, currentLatch) = getAndResetQueuedFiles() try { if (totalFiles > 0) { - UnindexedFilesIndexer(project, filesInQueue).queue(project) + UnindexedFilesIndexer(project, filesInQueue, reason).queue(project) } else { LOG.info("Finished for " + project.name + ". No files to index with loading content.") @@ -219,7 +219,8 @@ class PerProjectIndexingQueue(private val project: Project) : Disposable { val (filesInQueue, totalFiles, currentLatch) = getAndResetQueuedFiles() try { if (totalFiles > 0) { - UnindexedFilesIndexer(project, filesInQueue).indexFiles(projectIndexingHistory, indicator) + val indexingReason = projectIndexingHistory.indexingReason ?: "Flushing queue of project ${project.name}" + UnindexedFilesIndexer(project, filesInQueue, indexingReason).indexFiles(projectIndexingHistory, indicator) } else { LOG.info("Finished for " + project.name + ". No files to index with loading content.") diff --git a/platform/lang-impl/src/com/intellij/util/indexing/UnindexedFilesIndexer.java b/platform/lang-impl/src/com/intellij/util/indexing/UnindexedFilesIndexer.java index 6c552c902d92..2364e5782ccb 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/UnindexedFilesIndexer.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/UnindexedFilesIndexer.java @@ -22,6 +22,7 @@ import com.intellij.util.indexing.diagnostic.ProjectIndexingHistoryImpl; import com.intellij.util.indexing.diagnostic.ScanningType; import com.intellij.util.indexing.roots.IndexableFilesIterator; import com.intellij.util.indexing.snapshot.SnapshotInputMappingsStatistics; +import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; @@ -33,12 +34,15 @@ class UnindexedFilesIndexer extends DumbModeTask { private final Project myProject; private final FileBasedIndexImpl myIndex; private final Map> providerToFiles; + private final @NonNls @NotNull String indexingReason; UnindexedFilesIndexer(Project project, - Map> providerToFiles) { + Map> providerToFiles, + @NonNls @NotNull String indexingReason) { myProject = project; myIndex = (FileBasedIndexImpl)FileBasedIndex.getInstance(); this.providerToFiles = providerToFiles; + this.indexingReason = indexingReason; } void indexFiles(@NotNull ProjectIndexingHistoryImpl projectIndexingHistory, @@ -124,7 +128,7 @@ class UnindexedFilesIndexer extends DumbModeTask { if (!IndexInfrastructure.hasIndices()) { return; } - ProjectIndexingHistoryImpl projectIndexingHistory = new ProjectIndexingHistoryImpl(myProject, "Async indexing", ScanningType.REFRESH); + ProjectIndexingHistoryImpl projectIndexingHistory = new ProjectIndexingHistoryImpl(myProject, indexingReason, ScanningType.REFRESH); IndexDiagnosticDumper.getInstance().onIndexingStarted(projectIndexingHistory); ProgressSuspender suspender = ProgressSuspender.getSuspender(indicator); if (suspender != null) { @@ -173,7 +177,10 @@ class UnindexedFilesIndexer extends DumbModeTask { mergedFilesToIndex.put(e.getKey(), mergedList); } - return new UnindexedFilesIndexer(myProject, mergedFilesToIndex); + String mergedReason = "Merged " + StringUtil.trimStart(indexingReason, "Merged ") + + " with " + StringUtil.trimStart(otherIndexingTask.indexingReason, "Merged "); + + return new UnindexedFilesIndexer(myProject, mergedFilesToIndex, mergedReason); } private static double getPowerForSmoothProgressIndicator() { diff --git a/platform/lang-impl/src/com/intellij/util/indexing/UnindexedFilesScanner.java b/platform/lang-impl/src/com/intellij/util/indexing/UnindexedFilesScanner.java index 688a1044b940..751ab64fa075 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/UnindexedFilesScanner.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/UnindexedFilesScanner.java @@ -259,7 +259,7 @@ public class UnindexedFilesScanner implements MergeableQueueTask