diff --git a/dom/impl/src/com/intellij/util/xml/impl/DomManagerImpl.java b/dom/impl/src/com/intellij/util/xml/impl/DomManagerImpl.java index 504adbbc55b3..1d332f9fe78a 100644 --- a/dom/impl/src/com/intellij/util/xml/impl/DomManagerImpl.java +++ b/dom/impl/src/com/intellij/util/xml/impl/DomManagerImpl.java @@ -197,7 +197,7 @@ public final class DomManagerImpl extends DomManager implements ProjectComponent } } }; - //psiManager.addPsiTreeChangeListener(psiTreeChangeAdapter, project); + psiManager.addPsiTreeChangeListener(psiTreeChangeAdapter, project); /* StdLanguages.XML.injectAnnotator(new Annotator() { @@ -223,9 +223,7 @@ public final class DomManagerImpl extends DomManager implements ProjectComponent if (!element.isValid()) { for (final Set set : myFileDescriptions.values()) { for (final DomFileElementImpl fileElement : set) { - final XmlFile xmlFile = fileElement.getFile(); - updateFileDomness(xmlFile, null); - updateDependantFiles(xmlFile); + processFileChange(fileElement.getFile()); } } return; @@ -241,11 +239,8 @@ public final class DomManagerImpl extends DomManager implements ProjectComponent return; } - if (element instanceof PsiPackage) { - final PsiPackage psiPackage = (PsiPackage)element; - for (final PsiDirectory psiDirectory : psiPackage.getDirectories()) { - processDirectoryChange(psiDirectory); - } + for (final PsiDirectory psiDirectory : ((PsiPackage)element).getDirectories()) { + processDirectoryChange(psiDirectory); } } diff --git a/dom/impl/src/com/intellij/util/xml/impl/FileDescriptionCachedValueProvider.java b/dom/impl/src/com/intellij/util/xml/impl/FileDescriptionCachedValueProvider.java index 04a4c819ae2b..281f6c653a58 100644 --- a/dom/impl/src/com/intellij/util/xml/impl/FileDescriptionCachedValueProvider.java +++ b/dom/impl/src/com/intellij/util/xml/impl/FileDescriptionCachedValueProvider.java @@ -6,6 +6,7 @@ package com.intellij.util.xml.impl; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleUtil; import com.intellij.openapi.util.Condition; +import com.intellij.openapi.util.ModificationTracker; import com.intellij.psi.PsiManager; import com.intellij.psi.util.CachedValue; import com.intellij.psi.util.CachedValueProvider; @@ -31,7 +32,7 @@ import java.util.*; /** * @author peter */ -class FileDescriptionCachedValueProvider { +class FileDescriptionCachedValueProvider implements ModificationTracker { private final XmlFile myXmlFile; private boolean myInModel; private boolean myComputing; @@ -41,6 +42,7 @@ class FileDescriptionCachedValueProvider { private DomFileDescription myFileDescription; private final DomManagerImpl myDomManager; + private int myModCount; public FileDescriptionCachedValueProvider(final DomManagerImpl domManager, final XmlFile xmlFile) { myDomManager = domManager; @@ -81,6 +83,7 @@ class FileDescriptionCachedValueProvider { return list; } + myModCount++; final XmlFile originalFile = (XmlFile)myXmlFile.getOriginalFile(); final DomFileDescription description = originalFile != null ? myDomManager.getOrCreateCachedValueProvider(originalFile).getFileDescription() @@ -149,6 +152,7 @@ class FileDescriptionCachedValueProvider { } final Set deps = new HashSet(description.getDependencyItems(myXmlFile)); + deps.add(this); deps.add(myXmlFile); computeCachedValue(deps.toArray()); @@ -170,6 +174,7 @@ class FileDescriptionCachedValueProvider { } private void computeCachedValue(final Object[] dependencyItems) { + assert !myCachedValue.hasUpToDateValue(); getCachedValueProvider().dependencies = dependencyItems; myCachedValue.getValue(); } @@ -177,6 +182,8 @@ class FileDescriptionCachedValueProvider { private Object[] getAllDependencyItems() { final Set deps = new LinkedHashSet(); deps.add(PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT); + deps.add(this); + deps.add(myXmlFile); for (final DomFileDescription fileDescription : myDomManager.getFileDescriptions().keySet()) { deps.addAll(fileDescription.getDependencyItems(myXmlFile)); } @@ -188,6 +195,10 @@ class FileDescriptionCachedValueProvider { return myLastResult; } + public long getModificationCount() { + return myModCount; + } + private class MyCondition implements Condition { public Module module;