use of com.intellij.openapi.editor.impl.event.DocumentEventImpl in project intellij-community by JetBrains.
the class PersistentRangeHighlighterImpl method changedUpdateImpl.
@Override
protected void changedUpdateImpl(@NotNull DocumentEvent e) {
// todo Denis Zhdanov
DocumentEventImpl event = (DocumentEventImpl) e;
final boolean shouldTranslateViaDiff = isValid() && PersistentRangeMarkerUtil.shouldTranslateViaDiff(event, getStartOffset(), getEndOffset());
boolean wasTranslatedViaDiff = shouldTranslateViaDiff;
if (shouldTranslateViaDiff) {
wasTranslatedViaDiff = translatedViaDiff(e, event);
}
if (!wasTranslatedViaDiff) {
super.changedUpdateImpl(e);
if (isValid()) {
myLine = getDocument().getLineNumber(getStartOffset());
int endLine = getDocument().getLineNumber(getEndOffset());
if (endLine != myLine) {
setIntervalEnd(getDocument().getLineEndOffset(myLine));
}
}
}
if (isValid() && getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE) {
setIntervalStart(DocumentUtil.getFirstNonSpaceCharOffset(getDocument(), myLine));
setIntervalEnd(getDocument().getLineEndOffset(myLine));
}
}
use of com.intellij.openapi.editor.impl.event.DocumentEventImpl in project intellij-community by JetBrains.
the class DocumentImpl method updateText.
private void updateText(@NotNull ImmutableCharSequence newText, int offset, @NotNull CharSequence oldString, @NotNull CharSequence newString, boolean wholeTextReplaced, long newModificationStamp, int initialStartOffset, int initialOldLength) {
assertNotNestedModification();
myChangeInProgress = true;
try {
DocumentEvent event = new DocumentEventImpl(this, offset, oldString, newString, myModificationStamp, wholeTextReplaced, initialStartOffset, initialOldLength);
beforeChangedUpdate(event);
myTextString = null;
ImmutableCharSequence prevText = myText;
myText = newText;
// increment sequence before firing events so that modification sequence on commit will match this sequence now
sequence.incrementAndGet();
changedUpdate(event, newModificationStamp, prevText);
} finally {
myChangeInProgress = false;
}
}
use of com.intellij.openapi.editor.impl.event.DocumentEventImpl in project intellij-community by JetBrains.
the class ManualRangeMarker method getUpdatedRange.
@Nullable
public ManualRangeMarker getUpdatedRange(@NotNull DocumentEvent event, @NotNull FrozenDocument documentBefore) {
if (event instanceof RetargetRangeMarkers) {
int start = ((RetargetRangeMarkers) event).getStartOffset();
if (myStart >= start && myEnd <= ((RetargetRangeMarkers) event).getEndOffset()) {
int delta = ((RetargetRangeMarkers) event).getMoveDestinationOffset() - start;
return new ManualRangeMarker(myStart + delta, myEnd + delta, myGreedyLeft, myGreedyRight, mySurviveOnExternalChange, null);
}
}
if (mySurviveOnExternalChange && PersistentRangeMarkerUtil.shouldTranslateViaDiff(event, myStart, myEnd)) {
PersistentRangeMarker.LinesCols linesCols = myLinesCols != null ? myLinesCols : PersistentRangeMarker.storeLinesAndCols(documentBefore, myStart, myEnd);
Pair<TextRange, PersistentRangeMarker.LinesCols> pair = linesCols == null ? null : PersistentRangeMarker.translateViaDiff((DocumentEventImpl) event, linesCols);
if (pair != null) {
return new ManualRangeMarker(pair.first.getStartOffset(), pair.first.getEndOffset(), myGreedyLeft, myGreedyRight, true, pair.second);
}
}
TextRange range = RangeMarkerImpl.applyChange(event, myStart, myEnd, myGreedyLeft, myGreedyRight);
return range == null ? null : new ManualRangeMarker(range.getStartOffset(), range.getEndOffset(), myGreedyLeft, myGreedyRight, mySurviveOnExternalChange, null);
}
Aggregations