diff --git a/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/OpenFileCommand.kt b/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/OpenFileCommand.kt index ab279215145b..55ab031516d6 100644 --- a/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/OpenFileCommand.kt +++ b/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/OpenFileCommand.kt @@ -5,7 +5,6 @@ import com.intellij.ide.impl.ProjectUtil import com.intellij.openapi.application.EDT import com.intellij.openapi.components.service import com.intellij.openapi.components.serviceAsync -import com.intellij.openapi.fileEditor.FileEditorComposite import com.intellij.openapi.fileEditor.FileEditorManager import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx import com.intellij.openapi.fileEditor.impl.FileEditorOpenOptions @@ -37,7 +36,7 @@ import kotlin.time.Duration.Companion.seconds * Command opens file. * Example: %openFile -file [-suppressErrors] [-timeout ] [WARMUP] [-disableCodeAnalysis(-dsa) by default false] */ -open class OpenFileCommand(text: String, line: Int) : PerformanceCommandCoroutineAdapter(text, line) { +class OpenFileCommand(text: String, line: Int) : PerformanceCommandCoroutineAdapter(text, line) { companion object { const val NAME: @NonNls String = "openFile" const val PREFIX: @NonNls String = "$CMD_PREFIX$NAME" @@ -59,11 +58,11 @@ open class OpenFileCommand(text: String, line: Int) : PerformanceCommandCoroutin }.getOrNull() } } - + override fun getName(): String = NAME override suspend fun doExecute(context: PlaybackContext) { - val arguments = extractCommandArgument(prefix) + val arguments = extractCommandArgument(PREFIX) val options = getOptions(arguments) val filePath = (options?.file ?: text.split(' ', limit = 4)[1]).replace("SPACE_SYMBOL", " ") val timeout = options?.timeout ?: 0 @@ -101,7 +100,8 @@ open class OpenFileCommand(text: String, line: Int) : PerformanceCommandCoroutin openFileSpan = startSpan(OPEN_FILE_SPAN_NAME).setAttribute("path", file.path) } - val fileEditor = openEditor(project, file) + val fileEditor = (project.serviceAsync() as FileEditorManagerEx) + .openFile(file = file, options = FileEditorOpenOptions(requestFocus = true)) if (useWaitForCodeAnalysisCode(options)) { HighlightingTestUtil.waitForAnalysisWithNewApproach(project, spanRef, timeout, suppressErrors) @@ -123,12 +123,6 @@ open class OpenFileCommand(text: String, line: Int) : PerformanceCommandCoroutin } } - protected open suspend fun openEditor( - project: Project, - file: VirtualFile, - ): FileEditorComposite = (project.serviceAsync() as FileEditorManagerEx) - .openFile(file = file, options = FileEditorOpenOptions(requestFocus = true)) - private fun useWaitForCodeAnalysisCode(options: OpenFileCommandOptions?): Boolean = options != null && !options.disableCodeAnalysis && options.useNewWaitForCodeAnalysisCode