diff --git a/platform/core-impl/src/com/intellij/pom/core/impl/PomModelImpl.java b/platform/core-impl/src/com/intellij/pom/core/impl/PomModelImpl.java index 2a17f7832a70..b9fc9429d5ee 100644 --- a/platform/core-impl/src/com/intellij/pom/core/impl/PomModelImpl.java +++ b/platform/core-impl/src/com/intellij/pom/core/impl/PomModelImpl.java @@ -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 throwables = new ArrayList(0); @@ -357,4 +357,8 @@ public class PomModelImpl extends UserDataHolderBase implements PomModel { allowPsiModification = old; } } + + public static boolean isAllowPsiModification() { + return allowPsiModification; + } } diff --git a/platform/lang-impl/src/com/intellij/psi/impl/PsiDocumentManagerImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/PsiDocumentManagerImpl.java index 81726d53cc56..dd88dddcc23e 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/PsiDocumentManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/PsiDocumentManagerImpl.java @@ -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(); + } } }