move some more undesired PsiFileImpl dependencies into StubTreeLoader service
authorDmitry Jemerov <yole@jetbrains.com>
Fri, 2 Sep 2011 14:01:12 +0000 (16:01 +0200)
committerDmitry Jemerov <yole@jetbrains.com>
Mon, 5 Sep 2011 10:09:13 +0000 (12:09 +0200)
platform/lang-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java
platform/lang-impl/src/com/intellij/psi/stubs/StubTreeLoader.java
platform/lang-impl/src/com/intellij/psi/stubs/StubTreeLoaderImpl.java

index 0efa84fa7b024dfdb61b7e1d70a838f1d52be896..80cfd6a0f7689fd66d1f102944bcd520babab148 100644 (file)
@@ -58,8 +58,6 @@ import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.PatchedSoftReference;
 import com.intellij.util.PatchedWeakReference;
 import com.intellij.util.containers.ContainerUtil;
-import com.intellij.util.indexing.FileBasedIndex;
-import com.intellij.util.indexing.IndexingStamp;
 import com.intellij.util.text.CharArrayUtil;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -610,7 +608,7 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
     if (!(contentElementType instanceof IStubFileElementType)) {
       final FileViewProvider viewProvider = getViewProvider();
       throw new AssertionError("A stub in a non-stub file '" + vFile +"'; isValid()=" + vFile.isValid() + 
-                               "; IndexStamp="+ IndexingStamp.getIndexStamp(vFile, StubUpdatingIndex.INDEX_ID) +
+                               "; IndexStamp="+ StubTreeLoader.getInstance().getStubTreeTimestamp(vFile)  +
                                "; Type: " + contentElementType + "; " +
                                "Psi roots: " + viewProvider.getAllFiles() + "; " +
                                " StubUpdatingIndex.canHaveStub(vFile)=" + StubUpdatingIndex.canHaveStub(vFile) + 
@@ -950,7 +948,7 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
         }
       }, ModalityState.NON_MODAL);
 
-      FileBasedIndex.getInstance().requestReindex(vFile);
+      StubTreeLoader.getInstance().rebuildStubTree(vFile);
     }
   }
 
index 190d907dddd959b763cd05f02e8692940679412a..2b0c7fc7cd130f2ff26d4b3f503e8512b303a3a8 100644 (file)
@@ -30,4 +30,8 @@ public abstract class StubTreeLoader {
   public abstract StubTree readOrBuild(Project project, final VirtualFile vFile);
 
   public abstract StubTree readFromVFile(Project project, final VirtualFile vFile);
+  
+  public abstract void rebuildStubTree(VirtualFile virtualFile);
+
+  public abstract long getStubTreeTimestamp(VirtualFile vFile);
 }
index 634bc4411c4c68efb9c7b1591f79acfae69a0898..9d8f4071553887c58ad4d20592444ee540dc813d 100644 (file)
@@ -27,6 +27,7 @@ import com.intellij.psi.search.GlobalSearchScopes;
 import com.intellij.util.indexing.FileBasedIndex;
 import com.intellij.util.indexing.FileContent;
 import com.intellij.util.indexing.FileContentImpl;
+import com.intellij.util.indexing.IndexingStamp;
 import org.jetbrains.annotations.Nullable;
 
 import java.io.IOException;
@@ -98,4 +99,14 @@ public class StubTreeLoaderImpl extends StubTreeLoader {
 
     return null;
   }
+
+  @Override
+  public void rebuildStubTree(VirtualFile virtualFile) {
+    FileBasedIndex.getInstance().requestReindex(virtualFile);
+  }
+
+  @Override
+  public long getStubTreeTimestamp(VirtualFile vFile) {
+    return IndexingStamp.getIndexStamp(vFile, StubUpdatingIndex.INDEX_ID);
+  }
 }