mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Cleanup (unwarranted warnings; formatting)
This commit is contained in:
@@ -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<T> extends BaseActionRunnable<T> {
|
||||
* Must be called from the EDT.
|
||||
*/
|
||||
public static <E extends Throwable> void run(@NotNull ThrowableRunnable<E> 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<T> extends BaseActionRunnable<T> {
|
||||
* <br/>Instead, please use {@link #run(ThrowableRunnable)}.
|
||||
*/
|
||||
public static <E extends Throwable> void runAndWait(@NotNull ThrowableRunnable<E> 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<T> extends BaseActionRunnable<T> {
|
||||
if (application.isReadAccessAllowed()) {
|
||||
LOG.error("Must not start write action from within read action in the other thread - deadlock is coming");
|
||||
}
|
||||
final AtomicReference<T> result = new AtomicReference<>();
|
||||
final AtomicReference<Throwable> exception = new AtomicReference<>();
|
||||
|
||||
AtomicReference<T> result = new AtomicReference<>();
|
||||
AtomicReference<Throwable> exception = new AtomicReference<>();
|
||||
TransactionGuard.getInstance().submitTransactionAndWait(() -> {
|
||||
try {
|
||||
result.set(compute(action));
|
||||
@@ -169,9 +157,10 @@ public abstract class WriteAction<T> extends BaseActionRunnable<T> {
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user