platform: folding assertions relaxed to allow regions of length 1

This commit is contained in:
Roman Shevchenko
2014-06-23 19:44:32 +02:00
parent c6220ff4d1
commit 33ca415a45
3 changed files with 8 additions and 12 deletions
@@ -18,7 +18,6 @@ package com.intellij.lang.folding;
import com.intellij.lang.ASTNode;
import com.intellij.lang.Language;
import com.intellij.openapi.editor.FoldingGroup;
import com.intellij.openapi.util.ProperTextRange;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.util.ObjectUtils;
@@ -94,12 +93,11 @@ public class FoldingDescriptor {
@Nullable FoldingGroup group,
Set<Object> dependencies,
boolean neverExpands) {
assert range.getStartOffset() + 1 < range.getEndOffset() : range + ", text: " + node.getText() + ", language = " + node.getPsi().getLanguage();
assert range.getLength() > 0 : range + ", text: " + node.getText() + ", language = " + node.getPsi().getLanguage();
myElement = node;
ProperTextRange.assertProperRange(range);
TextRange.assertProperRange(range);
myRange = range;
myGroup = group;
assert getRange().getLength() >= 2 : "range:" + getRange();
myDependencies = dependencies;
assert !myDependencies.contains(null);
myNeverExpands = neverExpands;
@@ -91,7 +91,7 @@ public class FoldRegionImpl extends RangeMarkerImpl implements FoldRegion {
@Override
public boolean isValid() {
return super.isValid() && intervalStart() + 1 < intervalEnd();
return super.isValid() && intervalStart() < intervalEnd();
}
public void setExpandedInternal(boolean toExpand) {
@@ -529,12 +529,11 @@ public class FoldingModelImpl implements FoldingModelEx, PrioritizedDocumentList
}
@Override
public FoldRegion createFoldRegion(int startOffset, int endOffset, @NotNull String placeholder, @Nullable FoldingGroup group,
boolean neverExpands)
{
if (startOffset + 1 >= endOffset) {
LOG.error("Invalid offsets: ("+startOffset+", "+endOffset+")");
}
public FoldRegion createFoldRegion(int startOffset,
int endOffset,
@NotNull String placeholder,
@Nullable FoldingGroup group,
boolean neverExpands) {
FoldRegionImpl region = new FoldRegionImpl(myEditor, startOffset, endOffset, placeholder, group, neverExpands);
LOG.assertTrue(region.isValid());
return region;
@@ -551,7 +550,6 @@ public class FoldingModelImpl implements FoldingModelEx, PrioritizedDocumentList
});
}
private void notifyListenersOnFoldRegionStateChange(@NotNull FoldRegion foldRegion) {
for (FoldingListener listener : myListeners) {
listener.onFoldRegionStateChange(foldRegion);