mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
remove some unnecessary synchronous transactions
This commit is contained in:
@@ -47,24 +47,18 @@ public abstract class WriteAction<T> extends BaseActionRunnable<T> {
|
||||
LOG.error("Must not start write action from within read action in the other thread - deadlock is coming");
|
||||
}
|
||||
|
||||
application.invokeAndWait(new Runnable() {
|
||||
TransactionGuard.getInstance().submitTransactionAndWait(TransactionKind.ANY_CHANGE, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AccessToken transaction = TransactionGuard.getInstance().startSynchronousTransaction(TransactionKind.ANY_CHANGE);
|
||||
AccessToken token = start(WriteAction.this.getClass());
|
||||
try {
|
||||
AccessToken token = start(WriteAction.this.getClass());
|
||||
try {
|
||||
result.run();
|
||||
}
|
||||
finally {
|
||||
token.finish();
|
||||
}
|
||||
result.run();
|
||||
}
|
||||
finally {
|
||||
transaction.finish();
|
||||
token.finish();
|
||||
}
|
||||
}
|
||||
}, ModalityState.defaultModalityState());
|
||||
});
|
||||
|
||||
result.throwException();
|
||||
return result;
|
||||
|
||||
@@ -83,18 +83,12 @@ public abstract class WriteCommandAction<T> extends BaseActionRunnable<T> {
|
||||
performWriteCommandAction(result);
|
||||
} else {
|
||||
try {
|
||||
application.invokeAndWait(new Runnable() {
|
||||
TransactionGuard.getInstance().submitTransactionAndWait(TransactionKind.ANY_CHANGE, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AccessToken token = TransactionGuard.getInstance().startSynchronousTransaction(TransactionKind.ANY_CHANGE);
|
||||
try {
|
||||
performWriteCommandAction(result);
|
||||
}
|
||||
finally {
|
||||
token.finish();
|
||||
}
|
||||
performWriteCommandAction(result);
|
||||
}
|
||||
}, ModalityState.defaultModalityState());
|
||||
});
|
||||
}
|
||||
catch (ProcessCanceledException ignored) { }
|
||||
}
|
||||
|
||||
+1
-3
@@ -20,8 +20,6 @@ import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateState;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.application.TransactionGuard;
|
||||
import com.intellij.openapi.application.TransactionKind;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
||||
@@ -39,7 +37,7 @@ public class EscapeHandler extends EditorActionHandler {
|
||||
final TemplateState templateState = TemplateManagerImpl.getTemplateState(editor);
|
||||
if (templateState != null && !templateState.isFinished()) {
|
||||
CommandProcessor.getInstance().setCurrentCommandName(CodeInsightBundle.message("finish.template.command"));
|
||||
TransactionGuard.syncTransaction(TransactionKind.TEXT_EDITING, () -> templateState.gotoEnd(true));
|
||||
templateState.gotoEnd(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user