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 5a3247452d57..b98763e7767c 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 @@ -271,6 +271,8 @@ public class PomModelImpl extends UserDataHolderBase implements PomModel { PsiToDocumentSynchronizer synchronizer =((PsiDocumentManagerBase)PsiDocumentManager.getInstance(myProject)).getSynchronizer(); TextRange changedPsiRange = DocumentCommitProcessor.getChangedPsiRange(file, oldText, newText); + if (changedPsiRange == null) return; + final DiffLog log = BlockSupport.getInstance(myProject).reparseRange(file, changedPsiRange, newText, new EmptyProgressIndicator()); synchronizer.setIgnorePsiEvents(true); try { diff --git a/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitProcessor.java b/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitProcessor.java index 40da8f1f28bc..a42d7a1944f0 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitProcessor.java +++ b/platform/core-impl/src/com/intellij/psi/impl/DocumentCommitProcessor.java @@ -105,13 +105,17 @@ public abstract class DocumentCommitProcessor { final long startDocModificationTimeStamp = document.getModificationStamp(); final FileElement myTreeElementBeingReparsedSoItWontBeCollected = ((PsiFileImpl)file).calcTreeElement(); final CharSequence chars = document.getImmutableCharSequence(); + final CharSequence oldPsiText = myTreeElementBeingReparsedSoItWontBeCollected.getChars(); + final TextRange changedPsiRange = getChangedPsiRange(file, oldPsiText, chars); + if (changedPsiRange == null) { + return null; + } + final Boolean data = document.getUserData(BlockSupport.DO_NOT_REPARSE_INCREMENTALLY); if (data != null) { document.putUserData(BlockSupport.DO_NOT_REPARSE_INCREMENTALLY, null); file.putUserData(BlockSupport.DO_NOT_REPARSE_INCREMENTALLY, data); } - final CharSequence oldPsiText = myTreeElementBeingReparsedSoItWontBeCollected.getChars(); - final TextRange changedPsiRange = getChangedPsiRange(file, oldPsiText, chars); BlockSupport blockSupport = BlockSupport.getInstance(file.getProject()); final DiffLog diffLog = blockSupport.reparseRange(file, changedPsiRange, chars, task.indicator); @@ -135,6 +139,7 @@ public abstract class DocumentCommitProcessor { }; } + @Nullable public static TextRange getChangedPsiRange(@NotNull PsiFile file, @NotNull CharSequence oldPsiText, @NotNull CharSequence newDocumentText) { if (!file.getViewProvider().supportsIncrementalReparse(file.getLanguage())) { return new TextRange(0, newDocumentText.length()); @@ -142,7 +147,7 @@ public abstract class DocumentCommitProcessor { int commonPrefixLength = StringUtil.commonPrefixLength(oldPsiText, newDocumentText); if (commonPrefixLength == newDocumentText.length() && newDocumentText.length() == oldPsiText.length()) { - return new TextRange(0, newDocumentText.length()); + return null; } int commonSuffixLength = StringUtil.commonSuffixLength(oldPsiText, newDocumentText);