summaryrefslogtreecommitdiff
path: root/platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java')
-rw-r--r--platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java21
1 files changed, 13 insertions, 8 deletions
diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java b/platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java
index 1d96d820328a..dabb45cd7667 100644
--- a/platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java
+++ b/platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java
@@ -74,7 +74,6 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
protected PsiFile myOriginalFile = null;
private final FileViewProvider myViewProvider;
- private static final Key<Document> HARD_REFERENCE_TO_DOCUMENT = new Key<Document>("HARD_REFERENCE_TO_DOCUMENT");
private volatile Reference<StubTree> myStub;
protected final PsiManagerEx myManager;
private volatile Getter<FileElement> myTreeElementPointer; // SoftReference/WeakReference to ASTNode or a strong reference to a tree if the file is a DummyHolder
@@ -188,11 +187,7 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
Document cachedDocument = FileDocumentManager.getInstance().getCachedDocument(getViewProvider().getVirtualFile());
- final Document document = viewProvider.isEventSystemEnabled() ? viewProvider.getDocument() : null;
FileElement treeElement = createFileElement(viewProvider.getContents());
- if (document != null) {
- treeElement.putUserData(HARD_REFERENCE_TO_DOCUMENT, document);
- }
treeElement.setPsi(this);
List<Pair<StubBasedPsiElementBase, CompositeElement>> bindings = calcStubAstBindings(treeElement, cachedDocument);
@@ -375,12 +370,22 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
public void unloadContent() {
ApplicationManager.getApplication().assertWriteAccessAllowed();
- LOG.assertTrue(getTreeElement() != null);
clearCaches();
myViewProvider.beforeContentsSynchronized();
synchronized (PsiLock.LOCK) {
- myTreeElementPointer = null;
- clearStub("unloadContent");
+ FileElement treeElement = derefTreeElement();
+ DebugUtil.startPsiModification("unloadContent");
+ try {
+ if (treeElement != null) {
+ myTreeElementPointer = null;
+ treeElement.detachFromFile();
+ DebugUtil.onInvalidated(treeElement);
+ }
+ clearStub("unloadContent");
+ }
+ finally {
+ DebugUtil.finishPsiModification();
+ }
}
}