use of com.intellij.util.diff.FilesTooBigForDiffException in project intellij-community by JetBrains.
the class SrcFileAnnotator method doGetLineMapping.
@Nullable
private SoftReference<TIntIntHashMap> doGetLineMapping(final long date, boolean oldToNew, MyEditorBean editorBean) {
VirtualFile virtualFile = editorBean.getVFile();
final byte[] oldContent;
synchronized (LOCK) {
if (myOldContent == null) {
if (ApplicationManager.getApplication().isDispatchThread())
return null;
final LocalHistory localHistory = LocalHistory.getInstance();
byte[] byteContent = localHistory.getByteContent(virtualFile, new FileRevisionTimestampComparator() {
public boolean isSuitable(long revisionTimestamp) {
return revisionTimestamp < date;
}
});
if (byteContent == null && virtualFile.getTimeStamp() > date) {
byteContent = loadFromVersionControl(date, virtualFile);
}
myOldContent = new SoftReference<>(byteContent);
}
oldContent = myOldContent.get();
}
if (oldContent == null)
return null;
String[] coveredLines = getCoveredLines(oldContent, virtualFile);
final Document document = editorBean.getDocument();
if (document == null)
return null;
String[] currentLines = getUpToDateLines(document);
String[] oldLines = oldToNew ? coveredLines : currentLines;
String[] newLines = oldToNew ? currentLines : coveredLines;
Diff.Change change;
try {
change = Diff.buildChanges(oldLines, newLines);
} catch (FilesTooBigForDiffException e) {
LOG.info(e);
return null;
}
return new SoftReference<>(getCoverageVersionToCurrentLineMapping(change, oldLines.length));
}
use of com.intellij.util.diff.FilesTooBigForDiffException in project intellij-community by JetBrains.
the class PersistentRangeMarker method translateViaDiff.
@Nullable
static Pair<TextRange, LinesCols> translateViaDiff(@NotNull final DocumentEventImpl event, @NotNull LinesCols linesCols) {
try {
int myStartLine = event.translateLineViaDiffStrict(linesCols.myStartLine);
Document document = event.getDocument();
if (myStartLine < 0 || myStartLine >= document.getLineCount()) {
return null;
}
int start = document.getLineStartOffset(myStartLine) + linesCols.myStartColumn;
if (start >= document.getTextLength())
return null;
int myEndLine = event.translateLineViaDiffStrict(linesCols.myEndLine);
if (myEndLine < 0 || myEndLine >= document.getLineCount()) {
return null;
}
int end = document.getLineStartOffset(myEndLine) + linesCols.myEndColumn;
if (end > document.getTextLength() || end < start)
return null;
if (end > event.getDocument().getTextLength() || myEndLine < myStartLine || myStartLine == myEndLine && linesCols.myEndColumn < linesCols.myStartColumn || event.getDocument().getLineCount() < myEndLine) {
return null;
}
return Pair.create(new TextRange(start, end), new LinesCols(myStartLine, linesCols.myStartColumn, myEndLine, linesCols.myEndColumn));
} catch (FilesTooBigForDiffException e) {
return null;
}
}
Aggregations