mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Read/WriteAction: shorter calls, less stacktrace lines
This commit is contained in:
@@ -37,7 +37,7 @@ public abstract class ReadAction<T> extends BaseActionRunnable<T> {
|
||||
return ApplicationManager.getApplication().acquireReadActionLock();
|
||||
}
|
||||
|
||||
public static <E extends Throwable> void runReadAction(@NotNull ThrowableRunnable<E> action) throws E {
|
||||
public static <E extends Throwable> void run(@NotNull ThrowableRunnable<E> action) throws E {
|
||||
AccessToken token = start();
|
||||
try {
|
||||
action.run();
|
||||
@@ -46,8 +46,13 @@ public abstract class ReadAction<T> extends BaseActionRunnable<T> {
|
||||
}
|
||||
}
|
||||
|
||||
public static <T, E extends Throwable> T runReadAction(@NotNull ThrowableComputable<T, E> action) throws E {
|
||||
return ApplicationManager.getApplication().runReadAction(action);
|
||||
public static <T, E extends Throwable> T compute(@NotNull ThrowableComputable<T, E> action) throws E {
|
||||
AccessToken token = start();
|
||||
try {
|
||||
return action.compute();
|
||||
} finally {
|
||||
token.finish();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public abstract class WriteAction<T> extends BaseActionRunnable<T> {
|
||||
return ApplicationManager.getApplication().acquireWriteActionLock(clazz);
|
||||
}
|
||||
|
||||
public static <E extends Throwable> void runWriteAction(@NotNull ThrowableRunnable<E> action) throws E {
|
||||
public static <E extends Throwable> void run(@NotNull ThrowableRunnable<E> action) throws E {
|
||||
AccessToken token = start();
|
||||
try {
|
||||
action.run();
|
||||
@@ -85,7 +85,12 @@ public abstract class WriteAction<T> extends BaseActionRunnable<T> {
|
||||
}
|
||||
}
|
||||
|
||||
public static <T, E extends Throwable> T runWriteAction(@NotNull ThrowableComputable<T, E> action) throws E {
|
||||
return ApplicationManager.getApplication().runWriteAction(action);
|
||||
public static <T, E extends Throwable> T compute(@NotNull ThrowableComputable<T, E> action) throws E {
|
||||
AccessToken token = start();
|
||||
try {
|
||||
return action.compute();
|
||||
} finally {
|
||||
token.finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -186,7 +186,7 @@ public class ShowIntentionActionsHandler implements CodeInsightActionHandler {
|
||||
Runnable r = () -> action.invoke(project, pair.second, pair.first);
|
||||
try {
|
||||
if (action.startInWriteAction()) {
|
||||
WriteAction.runWriteAction(r::run);
|
||||
WriteAction.run(r::run);
|
||||
} else {
|
||||
r.run();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user