From 5a493946000b885fabc4aef0d1204d64bcb73bf1 Mon Sep 17 00:00:00 2001 From: Tomasz Pasternak Date: Wed, 11 Dec 2024 14:49:58 +0100 Subject: [PATCH] Revert "fix: Reduce freeze in ProjectUpdater (#7153)" (#7156) This reverts commit bdb2b486c8f612da4544484a8da7747a0cab6402. --- base/src/META-INF/blaze-base.xml | 3 -- .../idea/blaze/base/qsync/ProjectUpdater.java | 8 ++--- .../qsync/ProjectUpdaterThreadingUtils.kt | 33 ------------------- 3 files changed, 4 insertions(+), 40 deletions(-) delete mode 100644 base/src/com/google/idea/blaze/base/qsync/ProjectUpdaterThreadingUtils.kt diff --git a/base/src/META-INF/blaze-base.xml b/base/src/META-INF/blaze-base.xml index 18cddb8e893..f186817d8f7 100644 --- a/base/src/META-INF/blaze-base.xml +++ b/base/src/META-INF/blaze-base.xml @@ -424,9 +424,6 @@ - diff --git a/base/src/com/google/idea/blaze/base/qsync/ProjectUpdater.java b/base/src/com/google/idea/blaze/base/qsync/ProjectUpdater.java index ad8fd3426e8..a7026e015bc 100644 --- a/base/src/com/google/idea/blaze/base/qsync/ProjectUpdater.java +++ b/base/src/com/google/idea/blaze/base/qsync/ProjectUpdater.java @@ -37,6 +37,7 @@ import com.google.idea.blaze.qsync.project.ProjectPath; import com.google.idea.blaze.qsync.project.ProjectProto; import com.google.idea.blaze.qsync.project.ProjectProto.LibrarySource; +import com.google.idea.common.util.Transactions; import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider; import com.intellij.openapi.externalSystem.service.project.ProjectDataManager; import com.intellij.openapi.module.Module; @@ -115,7 +116,7 @@ public void onNewProjectSnapshot(Context context, QuerySyncProjectSnapshot gr private void updateProjectModel(ProjectProto.Project spec, Context context) { File imlDirectory = new File(BlazeDataStorage.getProjectDataDir(importSettings), "modules"); - ProjectUpdaterThreadingUtils.Companion.readWriteAction( + Transactions.submitWriteActionTransactionAndWait( () -> { IdeModifiableModelsProvider models = ProjectDataManager.getInstance().createModifiableModelsProvider(project); @@ -216,10 +217,9 @@ private void updateProjectModel(ProjectProto.Project spec, Context context) { .build(), workspaceLanguageSettings); } - + models.commit(); } - return models; - }, models -> models.commit()); + }); } private Library getOrCreateLibrary( diff --git a/base/src/com/google/idea/blaze/base/qsync/ProjectUpdaterThreadingUtils.kt b/base/src/com/google/idea/blaze/base/qsync/ProjectUpdaterThreadingUtils.kt deleted file mode 100644 index 354d2750d08..00000000000 --- a/base/src/com/google/idea/blaze/base/qsync/ProjectUpdaterThreadingUtils.kt +++ /dev/null @@ -1,33 +0,0 @@ -package com.google.idea.blaze.base.qsync - -import com.google.idea.common.util.Transactions -import com.intellij.openapi.application.readAndWriteAction -import com.intellij.openapi.diagnostic.Logger -import com.intellij.openapi.util.registry.Registry -import kotlinx.coroutines.runBlocking -import java.util.concurrent.Callable -import java.util.function.Consumer - -class ProjectUpdaterThreadingUtils { - companion object { - val logger = Logger.getInstance(ProjectUpdaterThreadingUtils::class.java) - fun readWriteAction(readPart: Callable, commit: Consumer) { - if (Registry.`is`("bazel.qsync.enable.coroutine.project.updater")) { - runBlocking { - readAndWriteAction { - logger.info("Starting read operation") - val ret = readPart.call() - writeAction { - commit.accept(ret) - } - } - } - } else { - Transactions.submitWriteActionTransactionAndWait { - val ret = readPart.call() - commit.accept(ret) - } - } - } - } -} \ No newline at end of file