EA-59827 - IOE: PomModelImpl.runTransaction

This commit is contained in:
Alexey Kudravtsev
2015-03-12 14:34:10 +03:00
parent 6d9dbfe88d
commit bf005c9faf
2 changed files with 13 additions and 5 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -134,7 +134,7 @@ public class PomModelImpl extends UserDataHolderBase implements PomModel {
@Override
public void runTransaction(@NotNull PomTransaction transaction) throws IncorrectOperationException{
if (!allowPsiModification) {
if (!isAllowPsiModification()) {
throw new IncorrectOperationException("Must not modify PSI inside save listener");
}
List<Throwable> throwables = new ArrayList<Throwable>(0);
@@ -357,4 +357,8 @@ public class PomModelImpl extends UserDataHolderBase implements PomModel {
allowPsiModification = old;
}
}
public static boolean isAllowPsiModification() {
return allowPsiModification;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -32,6 +32,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectLocator;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.core.impl.PomModelImpl;
import com.intellij.psi.FileViewProvider;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
@@ -104,7 +105,7 @@ public class PsiDocumentManagerImpl extends PsiDocumentManagerBase implements Se
@Override
public void documentChanged(DocumentEvent event) {
super.documentChanged(event);
// avoid documents piling up during batch processing
// optimisation: avoid documents piling up during batch processing
if (FileDocumentManagerImpl.areTooManyDocumentsInTheQueue(myUncommittedDocuments)) {
if (myUnitTestMode) {
myStopTrackingDocuments = true;
@@ -115,7 +116,10 @@ public class PsiDocumentManagerImpl extends PsiDocumentManagerBase implements Se
clearUncommittedDocuments();
}
}
commitAllDocuments();
// must not commit during document save
if (PomModelImpl.isAllowPsiModification()) {
commitAllDocuments();
}
}
}