mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
assert file & document validity on getText (EA-75987 - assert: ShredImpl.<init>)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user