From cea56d3953891bcbcd22886b554db6afb3104a62 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Wed, 5 Dec 2018 18:55:47 +0100 Subject: [PATCH] Cleanup (unwarranted warnings; formatting) --- .../openapi/application/WriteAction.java | 31 ++++++------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/platform/core-api/src/com/intellij/openapi/application/WriteAction.java b/platform/core-api/src/com/intellij/openapi/application/WriteAction.java index 941556378a8c..128eea9b7393 100644 --- a/platform/core-api/src/com/intellij/openapi/application/WriteAction.java +++ b/platform/core-api/src/com/intellij/openapi/application/WriteAction.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * 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. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.application; import com.intellij.openapi.diagnostic.Logger; @@ -101,7 +87,7 @@ public abstract class WriteAction extends BaseActionRunnable { * Must be called from the EDT. */ public static void run(@NotNull ThrowableRunnable action) throws E { - AccessToken token = start(action.getClass()); + @SuppressWarnings("deprecation") AccessToken token = start(action.getClass()); try { action.run(); } @@ -133,11 +119,12 @@ public abstract class WriteAction extends BaseActionRunnable { *
Instead, please use {@link #run(ThrowableRunnable)}. */ public static void runAndWait(@NotNull ThrowableRunnable action) throws E { - computeAndWait(()->{ + computeAndWait(() -> { action.run(); return null; }); } + /** * Executes {@code action} inside write action. * If called from outside the EDT, transfers control to the EDT first, executes write action there and waits for the execution end. @@ -154,8 +141,9 @@ public abstract class WriteAction extends BaseActionRunnable { if (application.isReadAccessAllowed()) { LOG.error("Must not start write action from within read action in the other thread - deadlock is coming"); } - final AtomicReference result = new AtomicReference<>(); - final AtomicReference exception = new AtomicReference<>(); + + AtomicReference result = new AtomicReference<>(); + AtomicReference exception = new AtomicReference<>(); TransactionGuard.getInstance().submitTransactionAndWait(() -> { try { result.set(compute(action)); @@ -169,9 +157,10 @@ public abstract class WriteAction extends BaseActionRunnable { if (t != null) { t.addSuppressed(new RuntimeException()); // preserve the calling thread stacktrace ExceptionUtil.rethrowUnchecked(t); - //noinspection unchecked - throw (E)t; + @SuppressWarnings("unchecked") E e = (E)t; + throw e; } + return result.get(); } } \ No newline at end of file