From ca809229decb4990e1fcb848d6d175bd8713604f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C5=82a=C5=BCej=20Kardy=C5=9B?= Date: Fri, 17 Jan 2025 19:06:40 +0100 Subject: [PATCH] Review fixes --- .../idea/blaze/base/qsync/ProjectUpdater.java | 4 ++-- .../base/qsync/ProjectUpdaterThreadingUtils.kt | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) 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 f3918593128..f4ea37158c9 100644 --- a/base/src/com/google/idea/blaze/base/qsync/ProjectUpdater.java +++ b/base/src/com/google/idea/blaze/base/qsync/ProjectUpdater.java @@ -121,12 +121,12 @@ 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.performWriteAction(() -> { + ProjectUpdaterThreadingUtils.performWriteAction(() -> { for (BlazeQuerySyncPlugin syncPlugin : BlazeQuerySyncPlugin.EP_NAME.getExtensions()) { syncPlugin.updateProjectSettingsForQuerySync(project, context, projectViewSet); } }); - ProjectUpdaterThreadingUtils.Companion.readWriteAction( + ProjectUpdaterThreadingUtils.readWriteAction( () -> { IdeModifiableModelsProvider models = ProjectDataManager.getInstance().createModifiableModelsProvider(project); diff --git a/base/src/com/google/idea/blaze/base/qsync/ProjectUpdaterThreadingUtils.kt b/base/src/com/google/idea/blaze/base/qsync/ProjectUpdaterThreadingUtils.kt index a7e28d0c50a..270ee3939c7 100644 --- a/base/src/com/google/idea/blaze/base/qsync/ProjectUpdaterThreadingUtils.kt +++ b/base/src/com/google/idea/blaze/base/qsync/ProjectUpdaterThreadingUtils.kt @@ -1,3 +1,18 @@ +/* + * Copyright 2025 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.google.idea.blaze.base.qsync import com.intellij.openapi.application.readAndWriteAction @@ -10,6 +25,8 @@ import java.util.function.Consumer class ProjectUpdaterThreadingUtils { companion object { val logger = Logger.getInstance(ProjectUpdaterThreadingUtils::class.java) + + @JvmStatic fun readWriteAction(readPart: Callable, commit: Consumer) { runBlocking { readAndWriteAction { @@ -22,6 +39,7 @@ class ProjectUpdaterThreadingUtils { } } + @JvmStatic fun performWriteAction(action: Runnable) { runBlocking { writeAction {