mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
to prevent OOME perform one lightweight document commit
(when there are many uncommitted documents during batch document changes)
This commit is contained in:
@@ -357,6 +357,13 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
|
||||
protected boolean finishCommitInWriteAction(@NotNull final Document document,
|
||||
@NotNull final List<Processor<Document>> finishProcessors,
|
||||
final boolean synchronously) {
|
||||
return finishCommitInWriteAction(document, finishProcessors, synchronously, false);
|
||||
}
|
||||
|
||||
protected boolean finishCommitInWriteAction(@NotNull final Document document,
|
||||
@NotNull final List<Processor<Document>> finishProcessors,
|
||||
final boolean synchronously,
|
||||
boolean forceNoPsiCommit) {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
if (myProject.isDisposed()) return false;
|
||||
assert !(document instanceof DocumentWindow);
|
||||
@@ -366,7 +373,7 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
|
||||
getSmartPointerManager().fastenBelts(virtualFile);
|
||||
}
|
||||
|
||||
FileViewProvider viewProvider = getCachedViewProvider(document);
|
||||
FileViewProvider viewProvider = forceNoPsiCommit ? null : getCachedViewProvider(document);
|
||||
|
||||
myIsCommitInProgress = true;
|
||||
boolean success = true;
|
||||
|
||||
@@ -53,6 +53,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
//todo listen & notifyListeners readonly events?
|
||||
@@ -124,7 +125,13 @@ public class PsiDocumentManagerImpl extends PsiDocumentManagerBase implements Se
|
||||
if (PomModelImpl.isAllowPsiModification()
|
||||
// it can happen that document(forUseInNonAWTThread=true) outside write action caused this
|
||||
&& ApplicationManager.getApplication().isWriteAccessAllowed()) {
|
||||
commitAllDocuments();
|
||||
// commit document to avoid OOME
|
||||
for (Document document : myUncommittedDocuments) {
|
||||
if (document != event.getDocument()) {
|
||||
finishCommitInWriteAction(document, Collections.emptyList(), true, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,11 +146,12 @@ public class PsiDocumentManagerImpl extends PsiDocumentManagerBase implements Se
|
||||
@Override
|
||||
protected boolean finishCommitInWriteAction(@NotNull Document document,
|
||||
@NotNull List<Processor<Document>> finishProcessors,
|
||||
boolean synchronously) {
|
||||
boolean synchronously,
|
||||
boolean forceNoPsiCommit) {
|
||||
if (ApplicationManager.getApplication().isWriteAccessAllowed()) { // can be false for non-physical PSI
|
||||
EditorWindowImpl.disposeInvalidEditors();
|
||||
}
|
||||
return super.finishCommitInWriteAction(document, finishProcessors, synchronously);
|
||||
return super.finishCommitInWriteAction(document, finishProcessors, synchronously, forceNoPsiCommit);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user