diff --git a/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/BaseCommandProvider.java b/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/BaseCommandProvider.java index dc1128089140..e5c67f9a7dc9 100644 --- a/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/BaseCommandProvider.java +++ b/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/BaseCommandProvider.java @@ -134,8 +134,7 @@ public final class BaseCommandProvider implements CommandProvider { Map.entry(CloseLookupCommand.PREFIX, CloseLookupCommand::new), Map.entry(OpenProblemViewPanelCommand.PREFIX, OpenProblemViewPanelCommand::new), Map.entry(AssertProblemsViewCountCommand.PREFIX, AssertProblemsViewCountCommand::new), - Map.entry(DetectProjectLeaksCommand.PREFIX, DetectProjectLeaksCommand::new), - Map.entry(WaitForReOpenedFileCommand.PREFIX, WaitForReOpenedFileCommand::new) + Map.entry(DetectProjectLeaksCommand.PREFIX, DetectProjectLeaksCommand::new) ); } } 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 55ab031516d6..9af2d372e4d6 100644 --- a/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/OpenFileCommand.kt +++ b/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/OpenFileCommand.kt @@ -21,7 +21,6 @@ import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.openapi.vfs.VirtualFile import com.jetbrains.performancePlugin.PerformanceTestingBundle import com.jetbrains.performancePlugin.utils.DaemonCodeAnalyzerListener -import com.jetbrains.performancePlugin.utils.HighlightingTestUtil import com.sampullara.cli.Args import io.opentelemetry.api.trace.Span import kotlinx.coroutines.Dispatchers @@ -104,7 +103,7 @@ class OpenFileCommand(text: String, line: Int) : PerformanceCommandCoroutineAdap .openFile(file = file, options = FileEditorOpenOptions(requestFocus = true)) if (useWaitForCodeAnalysisCode(options)) { - HighlightingTestUtil.waitForAnalysisWithNewApproach(project, spanRef, timeout, suppressErrors) + waitForAnalysisWithNewApproach(project, spanRef, timeout, suppressErrors) openFileSpan!!.end() return } diff --git a/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/WaitForReOpenedFileCommand.kt b/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/WaitForReOpenedFileCommand.kt deleted file mode 100644 index f8426269a25c..000000000000 --- a/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/commands/WaitForReOpenedFileCommand.kt +++ /dev/null @@ -1,55 +0,0 @@ -package com.jetbrains.performancePlugin.commands - -import com.intellij.openapi.diagnostic.logger -import com.intellij.openapi.fileEditor.FileEditorManager -import com.intellij.openapi.fileEditor.FileEditorManagerListener -import com.intellij.openapi.ui.playback.PlaybackContext -import com.intellij.openapi.util.io.toNioPathOrNull -import com.intellij.openapi.vfs.VirtualFile -import com.jetbrains.performancePlugin.PerformanceTestSpan -import com.jetbrains.performancePlugin.utils.HighlightingTestUtil -import io.opentelemetry.api.trace.Span -import io.opentelemetry.context.Context -import kotlinx.coroutines.sync.Mutex -import org.jetbrains.annotations.NonNls - -class WaitForReOpenedFileCommand(text: String, line: Int) : PerformanceCommandCoroutineAdapter(text, line) { - - companion object { - const val NAME: @NonNls String = "waitForReOpenedFile" - const val PREFIX: @NonNls String = "$CMD_PREFIX$NAME" - } - - override suspend fun doExecute(context: PlaybackContext) { - val myOptions = OpenFileCommand.getOptions(extractCommandArgument(PREFIX)) - val fileName = myOptions!!.file.toNioPathOrNull()!!.fileName.toString() - val connection = context.project.messageBus.connect() - var span: Span? = null - - val fileOpenedLock = Mutex(true) - connection.subscribe(FileEditorManagerListener.Before.FILE_EDITOR_MANAGER, object : FileEditorManagerListener.Before { - override fun beforeFileOpened(source: FileEditorManager, file: VirtualFile) { - logger().info("beforeFileOpened ${file.name}") - if (file.name != fileName) return - span = startSpan("reopenFileAfterIdeRestart", null, "filePath" to myOptions.file) - fileOpenedLock.unlock() - } - }) - - fileOpenedLock.lock() - - HighlightingTestUtil.waitForAnalysisWithNewApproach(context.project, span, myOptions.timeout, myOptions.suppressErrors) - connection.disconnect() - } - - private fun startSpan(spanName: String, parentSpan: Span?, attribute: Pair? = null): Span { - val builder = PerformanceTestSpan.TRACER.spanBuilder(spanName) - .setParent(if (parentSpan == null) PerformanceTestSpan.getContext() else Context.current().with(parentSpan)) - - if (attribute != null) builder.setAttribute(attribute.first, attribute.second) - return builder.startSpan() - } - - override fun getName(): String = NAME - -} \ No newline at end of file diff --git a/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/utils/HighlightingTestUtil.kt b/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/utils/HighlightingTestUtil.kt index 4d49fe853dcd..f6d5ba1f1423 100644 --- a/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/utils/HighlightingTestUtil.kt +++ b/plugins/performanceTesting/core/src/com/jetbrains/performancePlugin/utils/HighlightingTestUtil.kt @@ -1,18 +1,10 @@ // Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.jetbrains.performancePlugin.utils -import com.intellij.openapi.components.service -import com.intellij.openapi.project.Project import com.intellij.platform.diagnostic.telemetry.Scope import com.intellij.platform.diagnostic.telemetry.TelemetryManager import java.util.concurrent.TimeUnit import com.intellij.openapi.util.Pair -import com.intellij.openapi.util.Ref -import com.jetbrains.performancePlugin.commands.CodeAnalysisStateListener -import io.opentelemetry.api.trace.Span -import java.util.concurrent.TimeoutException -import kotlin.time.Duration.Companion.minutes -import kotlin.time.Duration.Companion.seconds class HighlightingTestUtil { @@ -29,25 +21,5 @@ class HighlightingTestUtil { span.end(System.currentTimeMillis(), TimeUnit.MILLISECONDS) } - - @JvmStatic - suspend fun waitForAnalysisWithNewApproach(project: Project, spanRef: Ref, timeout: Long, suppressErrors: Boolean) { - waitForAnalysisWithNewApproach(project, spanRef.get(), timeout, suppressErrors) - } - - @JvmStatic - suspend fun waitForAnalysisWithNewApproach(project: Project, span: Span?, timeout: Long, suppressErrors: Boolean) { - val timeoutDuration = if (timeout == 0L) 5.minutes else timeout.seconds - try { - project.service().waitAnalysisToFinish(timeoutDuration, !suppressErrors) - } - catch (e: TimeoutException) { - span?.setAttribute("timeout", "true") - } - finally { - span?.end() - } - } } - } \ No newline at end of file