From efceab83ad9e9f6ef0073c186c4b9fd159036b4b Mon Sep 17 00:00:00 2001 From: Dennis Ushakov Date: Thu, 7 May 2015 14:28:45 +0300 Subject: [PATCH] Revert "use PsiModificationTracker#getModificationCount so we won't get same modification count after stub/ast switch accidentally" This reverts commit 48217a564a00ba726a61680ea2682e32c87c465f. --- .../StructureViewComponent.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java b/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java index c03f11b94e97..ac5eef43e7cf 100644 --- a/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java +++ b/platform/lang-impl/src/com/intellij/ide/structureView/newStructureView/StructureViewComponent.java @@ -37,15 +37,13 @@ import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.project.IndexNotReadyException; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.SimpleToolWindowPanel; -import com.intellij.openapi.util.AsyncResult; -import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.util.Disposer; -import com.intellij.openapi.util.Key; +import com.intellij.openapi.util.*; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.pom.Navigatable; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiManager; +import com.intellij.psi.StubBasedPsiElement; +import com.intellij.psi.impl.source.tree.CompositeElement; import com.intellij.psi.util.PsiUtilCore; import com.intellij.ui.*; import com.intellij.ui.treeStructure.actions.CollapseAllAction; @@ -826,7 +824,15 @@ public class StructureViewComponent extends SimpleToolWindowPanel implements Tre modificationCountForChildren = ourSettingsModificationCount; } - final long currentStamp = myProject != null ? PsiManager.getInstance(myProject).getModificationTracker().getModificationCount() : -1; + final Object o = unwrapValue(getValue()); + long currentStamp = -1; + if (o instanceof StubBasedPsiElement && ((StubBasedPsiElement)o).getStub() != null) { + currentStamp = ((StubBasedPsiElement)o).getContainingFile().getModificationStamp(); + } else if (o instanceof PsiElement && ((PsiElement)o).getNode() instanceof CompositeElement) { + currentStamp = ((CompositeElement)((PsiElement)o).getNode()).getModificationCount(); + } else if (o instanceof ModificationTracker) { + currentStamp = ((ModificationTracker)o).getModificationCount(); + } if (childrenStamp != currentStamp) { resetChildren(); childrenStamp = currentStamp;