diff --git a/java/performancePlugin/src/com/intellij/java/performancePlugin/CreateJavaFileCommand.kt b/java/performancePlugin/src/com/intellij/java/performancePlugin/CreateJavaFileCommand.kt index a2997affd27e..7030d4a82d3e 100644 --- a/java/performancePlugin/src/com/intellij/java/performancePlugin/CreateJavaFileCommand.kt +++ b/java/performancePlugin/src/com/intellij/java/performancePlugin/CreateJavaFileCommand.kt @@ -52,8 +52,6 @@ class CreateJavaFileCommand(text: String, line: Int) : PerformanceCommandCorouti ) } - override fun getName(): String { - return NAME - } + override fun getName(): String = NAME } \ No newline at end of file diff --git a/plugins/kotlin/kotlin.performanceExtendedPlugin/src/com/intellij/performance/performancePlugin/commands/CreateKotlinFileCommand.kt b/plugins/kotlin/kotlin.performanceExtendedPlugin/src/com/intellij/performance/performancePlugin/commands/CreateKotlinFileCommand.kt index 11374368f33d..6194f732762e 100644 --- a/plugins/kotlin/kotlin.performanceExtendedPlugin/src/com/intellij/performance/performancePlugin/commands/CreateKotlinFileCommand.kt +++ b/plugins/kotlin/kotlin.performanceExtendedPlugin/src/com/intellij/performance/performancePlugin/commands/CreateKotlinFileCommand.kt @@ -57,8 +57,6 @@ class CreateKotlinFileCommand(text: String, line: Int) : PerformanceCommandCorou ) } - override fun getName(): String { - return NAME - } + override fun getName(): String = NAME } \ No newline at end of file diff --git a/plugins/performanceTesting/src/com/jetbrains/performancePlugin/BaseCommandProvider.java b/plugins/performanceTesting/src/com/jetbrains/performancePlugin/BaseCommandProvider.java index 7d9a93617c22..aa8a09a2dd79 100644 --- a/plugins/performanceTesting/src/com/jetbrains/performancePlugin/BaseCommandProvider.java +++ b/plugins/performanceTesting/src/com/jetbrains/performancePlugin/BaseCommandProvider.java @@ -26,7 +26,7 @@ public final class BaseCommandProvider implements CommandProvider { Map.entry(ExitAppWithTimeoutCommand.PREFIX, ExitAppWithTimeoutCommand::new), Map.entry(OpenFileWithTerminateCommand.PREFIX, OpenFileWithTerminateCommand::new), Map.entry(WaitForSmartCommand.PREFIX, WaitForSmartCommand::new), - Map.entry(WaitForVcsLogCommand.PREFIX, WaitForVcsLogCommand::new), + Map.entry(WaitVcsLogIndexingCommand.PREFIX, WaitVcsLogIndexingCommand::new), Map.entry(WaitForAsyncRefreshCommand.PREFIX, WaitForAsyncRefreshCommand::new), Map.entry(SingleInspectionCommand.PREFIX, SingleInspectionCommand::new), Map.entry(StartPowerSave.PREFIX, StartPowerSave::new), diff --git a/plugins/performanceTesting/src/com/jetbrains/performancePlugin/commands/WaitForVcsLogCommand.kt b/plugins/performanceTesting/src/com/jetbrains/performancePlugin/commands/WaitForVcsLogCommand.kt deleted file mode 100644 index 6b24ebcfe1a6..000000000000 --- a/plugins/performanceTesting/src/com/jetbrains/performancePlugin/commands/WaitForVcsLogCommand.kt +++ /dev/null @@ -1,69 +0,0 @@ -package com.jetbrains.performancePlugin.commands - -import com.intellij.openapi.application.EDT -import com.intellij.openapi.project.DumbService -import com.intellij.openapi.ui.playback.PlaybackContext -import com.intellij.util.concurrency.AppExecutorUtil -import com.intellij.vcs.log.data.index.VcsLogModifiableIndex -import com.intellij.vcs.log.data.index.isIndexingPaused -import com.intellij.vcs.log.data.index.needIndexing -import com.intellij.vcs.log.impl.VcsProjectLog.Companion.getInstance -import com.jetbrains.performancePlugin.utils.TimeArgumentHelper -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.CompletableDeferred -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch -import kotlinx.coroutines.time.withTimeoutOrNull -import java.time.Duration -import java.util.concurrent.ScheduledFuture -import java.util.concurrent.TimeUnit - -/** - * Command for waiting finishing of git log indexing process - * Example - %waitForGitLogIndexing 5s - */ -class WaitForVcsLogCommand(text: String, line: Int) : PerformanceCommandCoroutineAdapter(text, line) { - companion object { - const val NAME = "waitForGitLogIndexing" - const val PREFIX = CMD_PREFIX + NAME - } - - override suspend fun doExecute(context: PlaybackContext) { - DumbService.getInstance(context.project).waitForSmartMode() - - val logManager = getInstance(context.project).logManager ?: return - val dataManager = logManager.dataManager - val modifiableIndex = dataManager.index as VcsLogModifiableIndex - - val (timeout, timeunit) = TimeArgumentHelper.parse(extractCommandArgument(PREFIX)) - var pauseVerifier: ScheduledFuture<*>? = null - try { - //Schedule a task that will check if indexing was paused and trying to resume it - pauseVerifier = AppExecutorUtil - .getAppScheduledExecutorService() - .scheduleWithFixedDelay( - { - if (modifiableIndex.needIndexing() && modifiableIndex.isIndexingPaused()) { - CoroutineScope(Dispatchers.EDT).launch { - //modifiableIndex.toggleIndexing() - } - } - }, - 0, 2, TimeUnit.MILLISECONDS - ) - - val isIndexingCompleted = CompletableDeferred() - modifiableIndex.addListener { _ -> isIndexingCompleted.complete(true) } - - withTimeoutOrNull(Duration.of(timeout, timeunit)) { isIndexingCompleted.await() } - ?: throw RuntimeException("Git log indexing project wasn't finished in $timeout $timeunit") - } - finally { - pauseVerifier?.cancel(true) - } - } - - override fun getName(): String { - return PREFIX - } -} \ No newline at end of file diff --git a/plugins/performanceTesting/src/com/jetbrains/performancePlugin/commands/WaitJpsBuildCommand.kt b/plugins/performanceTesting/src/com/jetbrains/performancePlugin/commands/WaitJpsBuildCommand.kt index c554b1f91d0d..fdc0b3909629 100644 --- a/plugins/performanceTesting/src/com/jetbrains/performancePlugin/commands/WaitJpsBuildCommand.kt +++ b/plugins/performanceTesting/src/com/jetbrains/performancePlugin/commands/WaitJpsBuildCommand.kt @@ -59,8 +59,6 @@ class WaitJpsBuildCommand(text: String, line: Int) : PerformanceCommandCoroutine waitJpsProjectLoaded(context.project, timeout, timeunit) } - override fun getName(): String { - return NAME - } + override fun getName(): String = NAME } \ No newline at end of file diff --git a/plugins/performanceTesting/src/com/jetbrains/performancePlugin/commands/WaitVcsLogIndexingCommand.kt b/plugins/performanceTesting/src/com/jetbrains/performancePlugin/commands/WaitVcsLogIndexingCommand.kt new file mode 100644 index 000000000000..8fe8dac153cf --- /dev/null +++ b/plugins/performanceTesting/src/com/jetbrains/performancePlugin/commands/WaitVcsLogIndexingCommand.kt @@ -0,0 +1,42 @@ +package com.jetbrains.performancePlugin.commands + +import com.intellij.openapi.project.DumbService +import com.intellij.openapi.ui.playback.PlaybackContext +import com.intellij.vcs.log.data.index.VcsLogModifiableIndex +import com.intellij.vcs.log.data.index.needIndexing +import com.intellij.vcs.log.impl.VcsProjectLog.Companion.getInstance +import com.jetbrains.performancePlugin.utils.TimeArgumentHelper +import kotlinx.coroutines.CompletableDeferred +import kotlinx.coroutines.time.withTimeoutOrNull +import java.time.Duration + +/** + * Command for waiting finishing of git log indexing process + * Example - %waitVcsLogIndexing 5s + */ +class WaitVcsLogIndexingCommand(text: String, line: Int) : PerformanceCommandCoroutineAdapter(text, line) { + companion object { + const val NAME = "waitVcsLogIndexing" + const val PREFIX = CMD_PREFIX + NAME + } + + override suspend fun doExecute(context: PlaybackContext) { + DumbService.getInstance(context.project).waitForSmartMode() + + val logManager = getInstance(context.project).logManager ?: return + val dataManager = logManager.dataManager + val vcsIndex = dataManager.index as VcsLogModifiableIndex + + if (vcsIndex.needIndexing()) { + val (timeout, timeunit) = TimeArgumentHelper.parse(extractCommandArgument(PREFIX)) + val isIndexingCompleted = CompletableDeferred() + vcsIndex.addListener { _ -> isIndexingCompleted.complete(true) } + + withTimeoutOrNull(Duration.of(timeout, timeunit)) { isIndexingCompleted.await() } + ?: throw RuntimeException("Git log indexing project wasn't finished in $timeout $timeunit") + } + } + + override fun getName(): String = NAME + +} \ No newline at end of file