Read/WriteAction: shorter calls, less stacktrace lines

This commit is contained in:
peter
2016-03-24 08:07:09 +01:00
parent d423fd1c13
commit bbb164bda0
3 changed files with 17 additions and 7 deletions
@@ -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();
}
}
}
@@ -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();
}