assert file & document validity on getText (EA-75987 - assert: ShredImpl.<init>)

This commit is contained in:
peter
2015-12-02 11:29:35 +01:00
parent 27ced69e71
commit c2db059b34
2 changed files with 10 additions and 0 deletions
@@ -613,6 +613,10 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
Document delegate = window.getDelegate();
if (delegate instanceof FrozenDocument) return (DocumentEx)window;
if (!window.isValid()) {
throw new AssertionError("host committed: " + isCommitted(delegate) + ", window=" + window);
}
UncommittedInfo info = myUncommittedInfos.get(delegate);
DocumentWindow answer = info == null ? null : info.myFrozenWindows.get(document);
if (answer == null) answer = freezeWindow(window);
@@ -47,6 +47,7 @@ import com.intellij.psi.search.PsiElementProcessor;
import com.intellij.psi.search.SearchScope;
import com.intellij.psi.stubs.*;
import com.intellij.psi.tree.*;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.reference.SoftReference;
import com.intellij.util.FileContentUtilCore;
import com.intellij.util.IncorrectOperationException;
@@ -385,6 +386,10 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
@Override
public String getText() {
final ASTNode tree = derefTreeElement();
if (tree != null) return tree.getText();
PsiUtilCore.ensureValid(this);
return getViewProvider().getContents().toString();
}
@@ -393,6 +398,7 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
final ASTNode tree = derefTreeElement();
if (tree != null) return tree.getTextLength();
PsiUtilCore.ensureValid(this);
return getViewProvider().getContents().length();
}