From 5d2b60433d696d11ccc6f5dc28c47109fb425612 Mon Sep 17 00:00:00 2001 From: Anton Kapeliushok Date: Mon, 17 Mar 2025 15:34:10 +0000 Subject: [PATCH] RDO-3348: disable ides plugin installation for codecanvas Merge-request: IJ-MR-157773 Merged-by: Anton Kapeliushok (cherry picked from commit 0ee600a675822034c98bf5c054976cc2dd79bca0) IJ-MR-158217 GitOrigin-RevId: e9f4113000ac097028851c5f6feafc6c7fd4b3ef --- .../downloader/CodeWithMeClientDownloader.kt | 14 +++++---- .../downloader/CodeWithMeGuestLauncher.kt | 29 ++++++++++++------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/platform/remoteDev-util/src/com/intellij/remoteDev/downloader/CodeWithMeClientDownloader.kt b/platform/remoteDev-util/src/com/intellij/remoteDev/downloader/CodeWithMeClientDownloader.kt index 493ed547cac6..2e2b193efeaa 100644 --- a/platform/remoteDev-util/src/com/intellij/remoteDev/downloader/CodeWithMeClientDownloader.kt +++ b/platform/remoteDev-util/src/com/intellij/remoteDev/downloader/CodeWithMeClientDownloader.kt @@ -747,12 +747,16 @@ object CodeWithMeClientDownloader { fun runFrontendProcess( lifetime: Lifetime, url: String, - frontendInstallation: FrontendInstallation + frontendInstallation: FrontendInstallation, + enableBeforeRunHooks: Boolean = true, ): Lifetime { - try { - processBeforeRunHooks(frontendInstallation) - } catch (e: Throwable) { - LOG.error("Could not process hooks before launching client $frontendInstallation", e) + if (enableBeforeRunHooks) { + try { + processBeforeRunHooks(frontendInstallation) + } + catch (e: Throwable) { + LOG.error("Could not process hooks before launching client $frontendInstallation", e) + } } when (frontendInstallation) { is EmbeddedFrontendInstallation -> { diff --git a/platform/remoteDev-util/src/com/intellij/remoteDev/downloader/CodeWithMeGuestLauncher.kt b/platform/remoteDev-util/src/com/intellij/remoteDev/downloader/CodeWithMeGuestLauncher.kt index 11a42872212a..6823f9826451 100644 --- a/platform/remoteDev-util/src/com/intellij/remoteDev/downloader/CodeWithMeGuestLauncher.kt +++ b/platform/remoteDev-util/src/com/intellij/remoteDev/downloader/CodeWithMeGuestLauncher.kt @@ -38,17 +38,18 @@ object CodeWithMeGuestLauncher { clientBuild: BuildNumber?, url: String, @NlsContexts.DialogTitle product: String, - onDone: (Lifetime) -> Unit = {} + enableBeforeRunHooks: Boolean, + onDone: (Lifetime) -> Unit = {}, ) { if (!application.isDispatchThread) { // starting a task from background will call invokeLater, but with wrong modality, so do it ourselves - application.invokeLater({ downloadCompatibleClientAndLaunch(lifetime, project, clientBuild, url, product, onDone) }, ModalityState.any()) + application.invokeLater({ downloadCompatibleClientAndLaunch(lifetime, project, clientBuild, url, product, enableBeforeRunHooks, onDone) }, ModalityState.any()) return } val uri = UrlUtil.parseOrShowError(url, product) ?: return - if (runAlreadyDownloadedClient(clientBuild, lifetime, project, url, onDone)) { + if (runAlreadyDownloadedClient(clientBuild, lifetime, project, url, enableBeforeRunHooks, onDone)) { return } @@ -57,7 +58,7 @@ object CodeWithMeGuestLauncher { return } - ProgressManager.getInstance().run(DownloadAndLaunchClientTask(project, uri, lifetime, url, product, onDone)) + ProgressManager.getInstance().run(DownloadAndLaunchClientTask(project, uri, lifetime, url, product, enableBeforeRunHooks, onDone)) } private class DownloadAndLaunchClientTask( @@ -66,7 +67,8 @@ object CodeWithMeGuestLauncher { private val lifetime: Lifetime?, private val url: String, private val product: @NlsContexts.DialogTitle String, - private val onDone: (Lifetime) -> Unit + private val enableBeforeRunHooks: Boolean, + private val onDone: (Lifetime) -> Unit, ) : Backgroundable(project, RemoteDevUtilBundle.message("launcher.title"), true) { private var clientLifetime : Lifetime = Lifetime.Terminated @@ -99,7 +101,8 @@ object CodeWithMeGuestLauncher { frontendInstallation = frontendInstallation, urlForThinClient = url, product = product, - progressIndicator = progressIndicator + progressIndicator = progressIndicator, + enableBeforeRunHooks = enableBeforeRunHooks, ) } catch (t: Throwable) { @@ -120,7 +123,8 @@ object CodeWithMeGuestLauncher { aLifetime: Lifetime?, project: Project?, url: String, - onDone: (Lifetime) -> Unit + enableBeforeRunHooks: Boolean, + onDone: (Lifetime) -> Unit, ): Boolean { if (clientBuild == null) { return false @@ -141,7 +145,8 @@ object CodeWithMeGuestLauncher { val clientLifetime = CodeWithMeClientDownloader.runFrontendProcess( lifetime = lifetime, url = url, - frontendInstallation = frontendInstallation + frontendInstallation = frontendInstallation, + enableBeforeRunHooks = enableBeforeRunHooks, ) onDone(clientLifetime) return true @@ -166,13 +171,15 @@ object CodeWithMeGuestLauncher { return StandaloneFrontendInstallation(guestData.targetPath, clientBuild, null) } - fun runDownloadedFrontend(lifetime: Lifetime, frontendInstallation: FrontendInstallation, urlForThinClient: String, - @NlsContexts.DialogTitle product: String, progressIndicator: ProgressIndicator?): Lifetime { + fun runDownloadedFrontend( + lifetime: Lifetime, frontendInstallation: FrontendInstallation, urlForThinClient: String, + @NlsContexts.DialogTitle product: String, progressIndicator: ProgressIndicator?, enableBeforeRunHooks: Boolean, + ): Lifetime { // todo: offer to connect as-is? try { progressIndicator?.text = RemoteDevUtilBundle.message("launcher.launch.client") progressIndicator?.text2 = frontendInstallation.installationHome.pathString - val thinClientLifetime = CodeWithMeClientDownloader.runFrontendProcess(lifetime, urlForThinClient, frontendInstallation) + val thinClientLifetime = CodeWithMeClientDownloader.runFrontendProcess(lifetime, urlForThinClient, frontendInstallation, enableBeforeRunHooks) // Wait a bit until process will be launched and only after that finish task Thread.sleep(3000)