mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
more diagnostics for text mismatch on PsiDocumentManager.getDocument
GitOrigin-RevId: 5a80899e2e781124d234689a616a8b7815441b2a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
cb0492a662
commit
a1140ed737
@@ -385,7 +385,7 @@ public abstract class AbstractFileViewProvider extends UserDataHolderBase implem
|
||||
@NonNls
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getName() + "{myVirtualFile=" + myVirtualFile + ", content=" + getContent() + '}';
|
||||
return getClass().getName() + "{vFile=" + myVirtualFile + ", content=" + getContent() + ", eventSystemEnabled=" + isEventSystemEnabled() + '}';
|
||||
}
|
||||
|
||||
public abstract PsiFile getCachedPsi(@NotNull Language target);
|
||||
|
||||
@@ -8,7 +8,9 @@ import com.intellij.lang.injection.InjectedLanguageManager;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.*;
|
||||
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
|
||||
import com.intellij.openapi.diagnostic.Attachment;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.DocumentRunnable;
|
||||
import com.intellij.openapi.editor.event.DocumentEvent;
|
||||
@@ -169,11 +171,12 @@ public abstract class PsiDocumentManagerBase extends PsiDocumentManager implemen
|
||||
document = FileDocumentManager.getInstance().getDocument(viewProvider.getVirtualFile());
|
||||
if (document != null) {
|
||||
if (document.getTextLength() != file.getTextLength()) {
|
||||
String message = "Document/PSI mismatch: " + file + " (" + file.getClass() + "); physical=" + viewProvider.isPhysical();
|
||||
if (document.getTextLength() + file.getTextLength() < 8096) {
|
||||
message += "\n=== document ===\n" + document.getText() + "\n=== PSI ===\n" + file.getText();
|
||||
}
|
||||
throw new AssertionError(message);
|
||||
String message = "Document/PSI mismatch: " + file + " of " + file.getClass() +
|
||||
"; viewProvider=" + viewProvider +
|
||||
"; uncommitted=" + Arrays.toString(getUncommittedDocuments());
|
||||
throw new RuntimeExceptionWithAttachments(message,
|
||||
new Attachment("document.txt", document.getText()),
|
||||
new Attachment("psi.txt", file.getText()));
|
||||
}
|
||||
|
||||
if (!viewProvider.isPhysical()) {
|
||||
|
||||
Reference in New Issue
Block a user