diff --git a/java/java-tests/testSrc/com/intellij/util/indexing/IndexDiagnosticTest.kt b/java/java-tests/testSrc/com/intellij/util/indexing/IndexDiagnosticTest.kt index 87a98570e713..c1a0833833d2 100644 --- a/java/java-tests/testSrc/com/intellij/util/indexing/IndexDiagnosticTest.kt +++ b/java/java-tests/testSrc/com/intellij/util/indexing/IndexDiagnosticTest.kt @@ -11,6 +11,7 @@ import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase import com.intellij.util.SystemProperties import com.intellij.util.indexing.diagnostic.IndexDiagnosticDumper import com.intellij.util.indexing.diagnostic.IndexDiagnosticDumperUtils +import com.intellij.util.indexing.diagnostic.ScanningType import com.intellij.util.indexing.diagnostic.dto.* import com.intellij.util.indexing.diagnostic.dump.paths.PortableFilePath import org.junit.Assert @@ -74,7 +75,7 @@ class IndexDiagnosticTest : JavaCodeInsightFixtureTestCase() { projectName = "projectName", times = JsonProjectIndexingHistoryTimes( "reason", - false, + ScanningType.PARTIAL, JsonDuration(123), JsonDuration(456), JsonDuration(789), 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 3a6704ff2e9f..b8878cd81cbc 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexProjectHandler.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexProjectHandler.java @@ -93,7 +93,7 @@ public final class FileBasedIndexProjectHandler { @NotNull Project project, long refreshedFilesCalcDuration) { ProjectIndexingHistoryImpl projectIndexingHistory = - new ProjectIndexingHistoryImpl(project, "On refresh of " + files.size() + " files", ScanningType.REFRESH, false); + new ProjectIndexingHistoryImpl(project, "On refresh of " + files.size() + " files", ScanningType.REFRESH); IndexDiagnosticDumper.getInstance().onIndexingStarted(projectIndexingHistory); ((FileBasedIndexImpl)FileBasedIndex.getInstance()).fireUpdateStarted(project); diff --git a/platform/lang-impl/src/com/intellij/util/indexing/UnindexedFilesUpdater.java b/platform/lang-impl/src/com/intellij/util/indexing/UnindexedFilesUpdater.java index 843b2e5b12ac..56f4308347cf 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/UnindexedFilesUpdater.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/UnindexedFilesUpdater.java @@ -621,7 +621,7 @@ public class UnindexedFilesUpdater extends DumbModeTask { protected @NotNull ProjectIndexingHistoryImpl performScanningAndIndexing(@NotNull ProgressIndicator indicator) { ProjectIndexingHistoryImpl projectIndexingHistory = - new ProjectIndexingHistoryImpl(myProject, myIndexingReason, myScanningType, isFullIndexUpdate()); + new ProjectIndexingHistoryImpl(myProject, myIndexingReason, myScanningType); myIndex.loadIndexes(); myIndex.filesUpdateStarted(myProject, isFullIndexUpdate()); IndexDiagnosticDumper.getInstance().onIndexingStarted(projectIndexingHistory); diff --git a/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/ProjectIndexingHistory.kt b/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/ProjectIndexingHistory.kt index bff9457cd485..e879df76c5ef 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/ProjectIndexingHistory.kt +++ b/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/ProjectIndexingHistory.kt @@ -24,7 +24,6 @@ interface ProjectIndexingHistoryListener { interface ProjectIndexingHistory { val project: Project val indexingReason: String? - val scanningType: ScanningType val indexingSessionId: Long val times: IndexingTimes val scanningStatistics: List @@ -34,10 +33,10 @@ interface ProjectIndexingHistory { val visibleTimeToAllThreadsTimeRatio: Double } -enum class ScanningType { - FULL_FORCED, FULL_ON_PROJECT_OPEN, FULL, - PARTIAL_FORCED, PARTIAL, - REFRESH; +enum class ScanningType(val isFull: Boolean) { + FULL_FORCED(true), FULL_ON_PROJECT_OPEN(true), FULL(true), + PARTIAL_FORCED(false), PARTIAL(false), + REFRESH(false); companion object { fun merge(first: ScanningType, second: ScanningType): ScanningType = returnFirstFound(first, second, @@ -79,7 +78,7 @@ interface StatsPerIndexer { interface IndexingTimes { val indexingReason: String? - val wasFullRescanning: Boolean + val scanningType: ScanningType val updatingStart: ZonedDateTime val totalUpdatingTime: TimeNano val updatingEnd: ZonedDateTime diff --git a/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/ProjectIndexingHistoryFusReporterListener.kt b/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/ProjectIndexingHistoryFusReporterListener.kt index 010d16a1b7db..467a0714b276 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/ProjectIndexingHistoryFusReporterListener.kt +++ b/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/ProjectIndexingHistoryFusReporterListener.kt @@ -50,8 +50,7 @@ class ProjectIndexingHistoryFusReporterListener : ProjectIndexingHistoryListener ProjectIndexingHistoryFusReporter.reportIndexingFinished( projectIndexingHistory.project, projectIndexingHistory.indexingSessionId, - projectIndexingHistory.times.wasFullRescanning, - projectIndexingHistory.scanningType, + projectIndexingHistory.times.scanningType, projectIndexingHistory.times.totalUpdatingTime.toMillis(), projectIndexingHistory.times.indexingDuration.toMillis(), scanningTime, @@ -139,7 +138,6 @@ object ProjectIndexingHistoryFusReporter : CounterUsagesCollector() { fun reportIndexingFinished( project: Project, indexingSessionId: Long, - wasFullIndexing: Boolean, scanningType: ScanningType, totalTime: Long, indexingTime: Long, @@ -156,7 +154,7 @@ object ProjectIndexingHistoryFusReporter : CounterUsagesCollector() { indexingFinished.log( project, this.indexingSessionId.with(indexingSessionId), - this.isFullRescanning.with(wasFullIndexing), + this.isFullRescanning.with(scanningType.isFull), this.scanningType.with(scanningType), this.totalTime.with(totalTime), this.indexingTime.with(indexingTime), diff --git a/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/ProjectIndexingHistoryImpl.kt b/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/ProjectIndexingHistoryImpl.kt index abebdd3ce6c5..fa47fb1b29ec 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/ProjectIndexingHistoryImpl.kt +++ b/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/ProjectIndexingHistoryImpl.kt @@ -19,8 +19,7 @@ import kotlin.reflect.KMutableProperty1 @ApiStatus.Internal data class ProjectIndexingHistoryImpl(override val project: Project, override val indexingReason: String?, - override val scanningType: ScanningType, - private val wasFullRescanning: Boolean) : ProjectIndexingHistory { + private val scanningType: ScanningType) : ProjectIndexingHistory { private companion object { val indexingSessionIdSequencer = AtomicLong() val log = thisLogger() @@ -32,7 +31,7 @@ data class ProjectIndexingHistoryImpl(override val project: Project, override val times: IndexingTimes by ::timesImpl - private val timesImpl = IndexingTimesImpl(indexingReason = indexingReason, wasFullRescanning = wasFullRescanning, + private val timesImpl = IndexingTimesImpl(indexingReason = indexingReason, scanningType = scanningType, updatingStart = ZonedDateTime.now(ZoneOffset.UTC), totalUpdatingTime = System.nanoTime()) override val scanningStatistics = arrayListOf() @@ -325,7 +324,7 @@ data class ProjectIndexingHistoryImpl(override val project: Project, data class IndexingTimesImpl( override val indexingReason: String?, - override val wasFullRescanning: Boolean, + override val scanningType: ScanningType, override val updatingStart: ZonedDateTime, override var totalUpdatingTime: TimeNano, override var updatingEnd: ZonedDateTime = updatingStart, diff --git a/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/dto/JsonConverter.kt b/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/dto/JsonConverter.kt index f4cdd734479d..b2cddad8dd46 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/dto/JsonConverter.kt +++ b/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/dto/JsonConverter.kt @@ -84,7 +84,7 @@ fun IndexingFileSetStatistics.IndexedFile.toJson() = JsonFileProviderIndexStatis fun IndexingTimes.toJson() = JsonProjectIndexingHistoryTimes( indexingReason = indexingReason, - wasFullRescanning = wasFullRescanning, + scanningType = scanningType, totalUpdatingTime = JsonDuration(totalUpdatingTime), indexingTime = JsonDuration(indexingDuration.toNanos()), contentLoadingVisibleTime = JsonDuration(contentLoadingVisibleDuration.toNanos()), diff --git a/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/dto/JsonProjectIndexingHistoryTimes.kt b/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/dto/JsonProjectIndexingHistoryTimes.kt index 3d98eae9549a..d90b8ff2fc27 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/dto/JsonProjectIndexingHistoryTimes.kt +++ b/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/dto/JsonProjectIndexingHistoryTimes.kt @@ -3,12 +3,13 @@ package com.intellij.util.indexing.diagnostic.dto import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonInclude +import com.intellij.util.indexing.diagnostic.ScanningType @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) data class JsonProjectIndexingHistoryTimes( val indexingReason: String? = null, - val wasFullRescanning: Boolean = false, + val scanningType: ScanningType = ScanningType.FULL, val totalUpdatingTime: JsonDuration = JsonDuration(), val indexingTime: JsonDuration = JsonDuration(), val contentLoadingVisibleTime: JsonDuration = JsonDuration(), diff --git a/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/presentation/jsonToHtmlConverter.kt b/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/presentation/jsonToHtmlConverter.kt index d9fb3ca1f442..3e571fb0538f 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/presentation/jsonToHtmlConverter.kt +++ b/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/presentation/jsonToHtmlConverter.kt @@ -14,6 +14,7 @@ import com.intellij.util.indexing.diagnostic.JsonSharedIndexDiagnosticEvent import com.intellij.util.indexing.diagnostic.dto.* import org.intellij.lang.annotations.Language import org.jetbrains.annotations.Nls +import java.util.* fun createAggregateHtml( projectName: String, @@ -95,7 +96,7 @@ fun createAggregateHtml( td(diagnostic.appInfo.productCode + "-" + diagnostic.appInfo.build) //Indexing type section - td(if (diagnostic.indexingTimes.wasFullRescanning) "Full" else "Partial") + td(diagnostic.indexingTimes.scanningType.name.lowercase(Locale.ENGLISH).replace('_', ' ')) } } } @@ -378,7 +379,7 @@ fun JsonIndexDiagnostic.generateHtml(): String { if (times.indexingReason != null) { tr { td("Reason"); td(times.indexingReason) } } - tr { td("Full or partial"); td(if (times.wasFullRescanning) "full" else "partial") } + tr { td("Type"); td(times.scanningType.name.lowercase(Locale.ENGLISH).replace('_', ' ')) } tr { td("Finished at"); td(times.updatingEnd.presentableLocalDateTime()) } tr { td("Cancelled?"); td(times.wasInterrupted.toString()) } tr { td("Suspended time"); td(times.totalSuspendedTime.presentableDuration()) } diff --git a/platform/lang-impl/testSources/com/intellij/util/indexing/diagnostic/ProjectIndexingHistoryImplTest.kt b/platform/lang-impl/testSources/com/intellij/util/indexing/diagnostic/ProjectIndexingHistoryImplTest.kt index 48815e2328b0..0e9e7a373ee0 100644 --- a/platform/lang-impl/testSources/com/intellij/util/indexing/diagnostic/ProjectIndexingHistoryImplTest.kt +++ b/platform/lang-impl/testSources/com/intellij/util/indexing/diagnostic/ProjectIndexingHistoryImplTest.kt @@ -12,7 +12,7 @@ class ProjectIndexingHistoryImplTest { @Test fun `test observation missed the start of suspension (IDEA-281514)`() { - val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.PARTIAL, true) + val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.FULL) val time = Instant.now() history.stopSuspendingStages(time) history.startStage(ProjectIndexingHistoryImpl.Stage.Indexing, time.plusNanos(1)) @@ -27,7 +27,7 @@ class ProjectIndexingHistoryImplTest { @Test fun `test there may be actions after suspension`() { - val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.PARTIAL, true) + val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.FULL) val time = Instant.now() history.startStage(ProjectIndexingHistoryImpl.Stage.Indexing, time) history.suspendStages(time.plusNanos(1)) @@ -42,7 +42,7 @@ class ProjectIndexingHistoryImplTest { @Test fun `test there may be actions after suspension 2`() { - val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.PARTIAL, true) + val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.FULL) val time = Instant.now() history.startStage(ProjectIndexingHistoryImpl.Stage.Indexing, time) history.suspendStages(time.plusNanos(1)) @@ -58,7 +58,7 @@ class ProjectIndexingHistoryImplTest { @Test fun `test there may be actions after suspension 3`() { - val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.PARTIAL, true) + val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.FULL) val time = Instant.now() history.suspendStages(time) history.startStage(ProjectIndexingHistoryImpl.Stage.Indexing, time.plusNanos(1)) @@ -74,7 +74,7 @@ class ProjectIndexingHistoryImplTest { @Test fun `test there may be actions after suspension 4`() { - val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.PARTIAL, true) + val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.FULL) val time = Instant.now() history.startStage(ProjectIndexingHistoryImpl.Stage.Indexing, time) history.stopSuspendingStages(time.plusNanos(1)) @@ -89,7 +89,7 @@ class ProjectIndexingHistoryImplTest { @Test fun `test there may be actions after suspension 5`() { - val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.PARTIAL, true) + val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.FULL) val time = Instant.now() history.startStage(ProjectIndexingHistoryImpl.Stage.Indexing, time.plusNanos(1)) history.stopSuspendingStages(time.plusNanos(2)) @@ -106,7 +106,7 @@ class ProjectIndexingHistoryImplTest { @Test fun `test basic workflow`() { - val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.PARTIAL, true) + val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.FULL) val instant = Instant.now() history.startStage(ProjectIndexingHistoryImpl.Stage.PushProperties, instant) history.stopStage(ProjectIndexingHistoryImpl.Stage.PushProperties, instant.plusNanos(1)) @@ -122,7 +122,7 @@ class ProjectIndexingHistoryImplTest { @Test fun `test stage with suspension inside`() { - val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.PARTIAL, true) + val history = ProjectIndexingHistoryImpl(DummyProject.getInstance(), "test", ScanningType.FULL) val instant = Instant.now() history.startStage(ProjectIndexingHistoryImpl.Stage.PushProperties, instant) history.suspendStages(instant.plusNanos(1)) diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/project/DumbServiceImplTest.groovy b/platform/platform-tests/testSrc/com/intellij/openapi/project/DumbServiceImplTest.groovy index d3c019ff2e1e..29304c37706f 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/project/DumbServiceImplTest.groovy +++ b/platform/platform-tests/testSrc/com/intellij/openapi/project/DumbServiceImplTest.groovy @@ -172,7 +172,7 @@ class DumbServiceImplTest extends BasePlatformTestCase { def index = FileBasedIndex.getInstance() as FileBasedIndexImpl new IndexUpdateRunner(index, ConcurrencyUtil.newSameThreadExecutorService(), 1) .indexFiles(project, Collections.singletonList(new IndexUpdateRunner.FileSet(project, "child", [child])), - indicator, new ProjectIndexingHistoryImpl(getProject(), "Testing", ScanningType.PARTIAL, false)) + indicator, new ProjectIndexingHistoryImpl(getProject(), "Testing", ScanningType.PARTIAL)) } } catch (ProcessCanceledException e) { diff --git a/platform/platform-tests/testSrc/com/intellij/util/io/PersistencePerformanceTest.java b/platform/platform-tests/testSrc/com/intellij/util/io/PersistencePerformanceTest.java index b63b4b3a6790..7af410828c16 100644 --- a/platform/platform-tests/testSrc/com/intellij/util/io/PersistencePerformanceTest.java +++ b/platform/platform-tests/testSrc/com/intellij/util/io/PersistencePerformanceTest.java @@ -109,7 +109,7 @@ public class PersistencePerformanceTest extends BasePlatformTestCase { Thread.sleep(100); new IndexUpdateRunner(index, UnindexedFilesUpdater.GLOBAL_INDEXING_EXECUTOR, UnindexedFilesUpdater.getNumberOfIndexingThreads()) .indexFiles(getProject(), Collections.singletonList(new IndexUpdateRunner.FileSet(getProject(), "test files", files)), - new EmptyProgressIndicator(), new ProjectIndexingHistoryImpl(getProject(), "Testing", ScanningType.PARTIAL, false)); + new EmptyProgressIndicator(), new ProjectIndexingHistoryImpl(getProject(), "Testing", ScanningType.PARTIAL)); } for (Future future : futures) { assertTrue(future.get());