use of com.intellij.openapi.editor.impl.ManualRangeMarker in project intellij-community by JetBrains.
the class MarkerCache method applyEvents.
private static UpdatedRanges applyEvents(@NotNull List<DocumentEvent> events, final UpdatedRanges struct) {
FrozenDocument frozen = struct.myResultDocument;
ManualRangeMarker[] resultMarkers = struct.myMarkers.clone();
for (DocumentEvent event : events) {
final FrozenDocument before = frozen;
final DocumentEvent corrected;
if (event instanceof RetargetRangeMarkers) {
RetargetRangeMarkers retarget = (RetargetRangeMarkers) event;
corrected = new RetargetRangeMarkers(frozen, retarget.getStartOffset(), retarget.getEndOffset(), retarget.getMoveDestinationOffset());
} else {
corrected = new DocumentEventImpl(frozen, event.getOffset(), event.getOldFragment(), event.getNewFragment(), event.getOldTimeStamp(), event.isWholeTextReplaced(), ((DocumentEventImpl) event).getInitialStartOffset(), ((DocumentEventImpl) event).getInitialOldLength());
frozen = frozen.applyEvent(event, 0);
}
int i = 0;
while (i < resultMarkers.length) {
ManualRangeMarker currentRange = resultMarkers[i];
int sameMarkersEnd = i + 1;
while (sameMarkersEnd < resultMarkers.length && resultMarkers[sameMarkersEnd] == currentRange) {
sameMarkersEnd++;
}
ManualRangeMarker updatedRange = currentRange == null ? null : currentRange.getUpdatedRange(corrected, before);
while (i < sameMarkersEnd) {
resultMarkers[i] = updatedRange;
i++;
}
}
}
return new UpdatedRanges(struct.myEventCount + events.size(), frozen, struct.mySortedInfos, resultMarkers);
}
use of com.intellij.openapi.editor.impl.ManualRangeMarker in project intellij-community by JetBrains.
the class MarkerCache method createMarkers.
@NotNull
private static ManualRangeMarker[] createMarkers(List<SelfElementInfo> infos) {
ManualRangeMarker[] markers = new ManualRangeMarker[infos.size()];
int i = 0;
while (i < markers.length) {
SelfElementInfo info = infos.get(i);
boolean greedy = info.isGreedy();
int start = info.getPsiStartOffset();
int end = info.getPsiEndOffset();
markers[i] = new ManualRangeMarker(start, end, greedy, greedy, !greedy, null);
i++;
while (i < markers.length && rangeEquals(infos.get(i), start, end, greedy)) {
markers[i] = markers[i - 1];
i++;
}
}
return markers;
}
use of com.intellij.openapi.editor.impl.ManualRangeMarker in project intellij-community by JetBrains.
the class MarkerCache method getUpdatedRange.
@Nullable
TextRange getUpdatedRange(@NotNull SelfElementInfo info, @NotNull FrozenDocument frozen, @NotNull List<DocumentEvent> events) {
UpdatedRanges struct = getUpdatedMarkers(frozen, events);
int i = Collections.binarySearch(struct.mySortedInfos, info, INFO_COMPARATOR);
ManualRangeMarker updated = i >= 0 ? struct.myMarkers[i] : null;
return updated == null ? null : new UnfairTextRange(updated.getStartOffset(), updated.getEndOffset());
}
Aggregations