use of com.intellij.openapi.diagnostic.Attachment in project intellij-community by JetBrains.
the class ExtendWordSelectionHandlerBase method select.
@Override
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
final TextRange originalRange = e.getTextRange();
if (originalRange.getEndOffset() > editorText.length()) {
throw new LogEventException("Invalid element range in " + getClass(), "element=" + e + "; range=" + originalRange + "; text length=" + editorText.length() + "; editor=" + editor + "; committed=" + PsiDocumentManager.getInstance(e.getProject()).isCommitted(editor.getDocument()), new Attachment("editor_text.txt", editorText.toString()), new Attachment("psi_text.txt", e.getText()));
}
List<TextRange> ranges = expandToWholeLine(editorText, originalRange, true);
if (ranges.size() == 1 && ranges.contains(originalRange)) {
return expandToWholeLine(editorText, originalRange, false);
}
return ranges;
}
use of com.intellij.openapi.diagnostic.Attachment in project intellij-community by JetBrains.
the class UpToDateStubIndexMismatch method stubTreeAndIndexDoNotMatch.
@NotNull
public RuntimeException stubTreeAndIndexDoNotMatch(@NotNull String _message, @NotNull ObjectStubTree stubTree, @NotNull PsiFileWithStubSupport psiFile) {
VirtualFile file = psiFile.getViewProvider().getVirtualFile();
StubTree stubTreeFromIndex = (StubTree) readFromVFile(psiFile.getProject(), file);
Document document = FileDocumentManager.getInstance().getDocument(file);
IndexingStampInfo indexingStampInfo = getIndexingStampInfo(file);
boolean upToDate = indexingStampInfo != null && indexingStampInfo.isUpToDate(document, file, psiFile);
String msg = _message + "\nPlease report the problem to JetBrains with the files attached\n";
if (upToDate) {
msg += "INDEXED VERSION IS THE CURRENT ONE";
}
msg += " file=" + psiFile;
msg += ", file.class=" + psiFile.getClass();
msg += ", file.lang=" + psiFile.getLanguage();
msg += ", modStamp=" + psiFile.getModificationStamp();
if (!(psiFile instanceof PsiCompiledElement)) {
String text = psiFile.getText();
PsiFile fromText = PsiFileFactory.getInstance(psiFile.getProject()).createFileFromText(psiFile.getName(), psiFile.getFileType(), text);
if (fromText.getLanguage().equals(psiFile.getLanguage())) {
boolean consistent = DebugUtil.psiToString(psiFile, true).equals(DebugUtil.psiToString(fromText, true));
if (consistent) {
msg += "\n tree consistent";
} else {
msg += "\n AST INCONSISTENT, perhaps after incremental reparse; " + fromText;
}
}
}
msg += "\n stub debugInfo=" + stubTree.getDebugInfo();
msg += "\nlatestIndexedStub=" + stubTreeFromIndex;
if (stubTreeFromIndex != null) {
msg += "\n same size=" + (stubTree.getPlainList().size() == stubTreeFromIndex.getPlainList().size());
msg += "\n debugInfo=" + stubTreeFromIndex.getDebugInfo();
}
FileViewProvider viewProvider = psiFile.getViewProvider();
msg += "\n viewProvider=" + viewProvider;
msg += "\n viewProvider stamp: " + viewProvider.getModificationStamp();
msg += "; file stamp: " + file.getModificationStamp();
msg += "; file modCount: " + file.getModificationCount();
msg += "; file length: " + file.getLength();
if (document != null) {
msg += "\n doc saved: " + !FileDocumentManager.getInstance().isDocumentUnsaved(document);
msg += "; doc stamp: " + document.getModificationStamp();
msg += "; doc size: " + document.getTextLength();
msg += "; committed: " + PsiDocumentManager.getInstance(psiFile.getProject()).isCommitted(document);
}
msg += "\nin many projects: " + hasPsiInManyProjects(file);
msg += "\nindexing info: " + indexingStampInfo;
Attachment[] attachments = createAttachments(stubTree, psiFile, file, stubTreeFromIndex);
// separate methods and separate exception classes for EA to treat these situations differently
return upToDate ? handleUpToDateMismatch(msg, attachments) : new RuntimeExceptionWithAttachments(msg, attachments);
}
use of com.intellij.openapi.diagnostic.Attachment in project intellij-community by JetBrains.
the class SingleRootFileViewProvider method checkLengthConsistency.
private void checkLengthConsistency() {
Document document = getCachedDocument();
if (document instanceof DocumentWindow) {
return;
}
if (document != null && ((PsiDocumentManagerBase) PsiDocumentManager.getInstance(myManager.getProject())).getSynchronizer().isInSynchronization(document)) {
return;
}
List<FileElement> knownTreeRoots = getKnownTreeRoots();
if (knownTreeRoots.isEmpty())
return;
int fileLength = myContent.getTextLength();
for (FileElement fileElement : knownTreeRoots) {
int nodeLength = fileElement.getTextLength();
if (nodeLength != fileLength) {
PsiUtilCore.ensureValid(fileElement.getPsi());
List<Attachment> attachments = ContainerUtil.newArrayList(new Attachment(myVirtualFile.getNameWithoutExtension() + ".tree.txt", fileElement.getText()), new Attachment(myVirtualFile.getNameWithoutExtension() + ".file.txt", myContent.toString()));
if (document != null) {
attachments.add(new Attachment(myVirtualFile.getNameWithoutExtension() + ".document.txt", document.getText()));
}
// exceptions here should be assigned to peter
LOG.error("Inconsistent " + fileElement.getElementType() + " tree in " + this + "; nodeLength=" + nodeLength + "; fileLength=" + fileLength, attachments.toArray(Attachment.EMPTY_ARRAY));
}
}
}
use of com.intellij.openapi.diagnostic.Attachment in project intellij-community by JetBrains.
the class TextLayoutCache method documentChanged.
@Override
public void documentChanged(DocumentEvent event) {
int startLine = myDocument.getLineNumber(event.getOffset());
int newEndLine = getAdjustedLineNumber(event.getOffset() + event.getNewLength());
invalidateLines(startLine, myDocumentChangeOldEndLine, newEndLine, true, LineLayout.isBidiLayoutRequired(event.getNewFragment()));
if (myLines.size() != myDocument.getLineCount()) {
LOG.error("Error updating text layout cache after " + event, new Attachment("editorState.txt", myView.getEditor().dumpState()));
resetToDocumentSize(true);
}
}
use of com.intellij.openapi.diagnostic.Attachment in project intellij-community by JetBrains.
the class TextLayoutCache method resetToDocumentSize.
void resetToDocumentSize(boolean documentChangedWithoutNotification) {
checkDisposed();
invalidateLines(0, myLines.size() - 1, myDocument.getLineCount() - 1, documentChangedWithoutNotification, documentChangedWithoutNotification);
if (myLines.size() != myDocument.getLineCount()) {
LOG.error("Error resetting text layout cache", new Attachment("editorState.txt", myView.getEditor().dumpState()));
}
}
Aggregations