revert, because out of range check is already there in getSaveRMTree (for IDEA-CR-39543)

This commit is contained in:
Alexey Kudravtsev
2018-11-09 19:07:02 +03:00
parent fbf21f0e21
commit 121cdf2da3
2 changed files with 15 additions and 23 deletions
@@ -168,8 +168,7 @@ class RangeMarkerTree<T extends RangeMarkerEx> extends IntervalTreeImpl<T> imple
incModCount();
List<IntervalNode<T>> affected = new SmartList<>();
int oldDocumentLength = e.getDocument().getTextLength() + e.getOldLength() - e.getNewLength();
collectAffectedMarkersAndShiftSubtrees(getRoot(), e, oldDocumentLength, affected);
collectAffectedMarkersAndShiftSubtrees(getRoot(), e, affected);
checkMax(false);
if (!affected.isEmpty()) {
@@ -199,9 +198,6 @@ class RangeMarkerTree<T extends RangeMarkerEx> extends IntervalTreeImpl<T> imple
Getter<T> key = keys.get(i);
marker = (RangeMarkerImpl)key.get();
if (marker != null) {
if (marker.isValid() && (marker.getStartOffset() < 0 || marker.getEndOffset() > oldDocumentLength)) {
marker.invalidate(e);
}
if (!marker.isValid()) {
// marker can become invalid on its own, e.g. FoldRegion
node.removeIntervalInternal(i);
@@ -224,9 +220,8 @@ class RangeMarkerTree<T extends RangeMarkerEx> extends IntervalTreeImpl<T> imple
}
checkMax(true);
// can be false when create lazy range marker from virtual file with invalid (e.g. too large) offset (with no ability to verify the offset at creation time)
//IntervalNode<T> root = getRoot();
//assert root == null || root.maxEnd + root.delta <= e.getDocument().getTextLength();
IntervalNode<T> root = getRoot();
assert root == null || root.maxEnd + root.delta <= e.getDocument().getTextLength();
}
finally {
l.writeLock().unlock();
@@ -244,8 +239,8 @@ class RangeMarkerTree<T extends RangeMarkerEx> extends IntervalTreeImpl<T> imple
// returns true if all deltas involved are still 0
boolean collectAffectedMarkersAndShiftSubtrees(@Nullable IntervalNode<T> root,
@NotNull DocumentEvent e, int oldDocumentLength,
@NotNull List<? super IntervalNode<T>> affected) {
@NotNull DocumentEvent e,
@NotNull List<? super IntervalNode<T>> affected) {
if (root == null) return true;
boolean norm = pushDelta(root);
@@ -255,11 +250,11 @@ class RangeMarkerTree<T extends RangeMarkerEx> extends IntervalTreeImpl<T> imple
int offset = e.getOffset();
int affectedEndOffset = offset + e.getOldLength();
boolean hasAliveKeys = root.hasAliveKey(false);
if (!hasAliveKeys || root.intervalEnd() > oldDocumentLength) {
// marker was garbage collected or its offsets become invalid (e.g. after loading document for range marker created from virtual file with invalid offsets)
if (!hasAliveKeys) {
// marker was garbage collected
affected.add(root);
}
if (offset > maxEnd && maxEnd <= oldDocumentLength) {
if (offset > maxEnd) {
// no need to bother
}
else if (affectedEndOffset < root.intervalStart()) {
@@ -273,21 +268,18 @@ class RangeMarkerTree<T extends RangeMarkerEx> extends IntervalTreeImpl<T> imple
norm &= newL == 0;
}
norm &= pushDelta(root);
norm &= collectAffectedMarkersAndShiftSubtrees(left, e, oldDocumentLength, affected);
if (maxEnd > oldDocumentLength) {
collectAffectedMarkersAndShiftSubtrees(root.getRight(), e, oldDocumentLength, affected);
}
norm &= collectAffectedMarkersAndShiftSubtrees(left, e, affected);
correctMax(root, 0);
}
else {
if (offset <= root.intervalEnd()) {
// unlucky enough so that change affects the interval
if (affected.isEmpty() || affected.get(affected.size()-1) != root) affected.add(root); // otherwise we've already added it
if (hasAliveKeys) affected.add(root); // otherwise we've already added it
root.setValid(false); //make invisible
}
norm &= collectAffectedMarkersAndShiftSubtrees(root.getLeft(), e, oldDocumentLength, affected);
norm &= collectAffectedMarkersAndShiftSubtrees(root.getRight(), e, oldDocumentLength, affected);
norm &= collectAffectedMarkersAndShiftSubtrees(root.getLeft(), e, affected);
norm &= collectAffectedMarkersAndShiftSubtrees(root.getRight(), e, affected);
correctMax(root,0);
}
return norm;
@@ -754,12 +754,12 @@ public class FoldingModelImpl extends InlayModel.SimpleAdapter
@Override
boolean collectAffectedMarkersAndShiftSubtrees(@Nullable IntervalNode<FoldRegionImpl> root,
@NotNull DocumentEvent e,
int oldDocumentLength, @NotNull List<? super IntervalNode<FoldRegionImpl>> affected) {
if (inCollectCall) return super.collectAffectedMarkersAndShiftSubtrees(root, e, oldDocumentLength, affected);
@NotNull List<? super IntervalNode<FoldRegionImpl>> affected) {
if (inCollectCall) return super.collectAffectedMarkersAndShiftSubtrees(root, e, affected);
inCollectCall = true;
boolean result;
try {
result = super.collectAffectedMarkersAndShiftSubtrees(root, e, oldDocumentLength, affected);
result = super.collectAffectedMarkersAndShiftSubtrees(root, e, affected);
}
finally {
inCollectCall = false;