EA-78555 - assert: Block.<init>

accept invalid ranges as initial Block - throw exception for computed ones only
This commit is contained in:
Aleksey Pivovarov
2016-02-01 17:33:22 +03:00
parent c93acc790f
commit d303036e82
@@ -39,13 +39,9 @@ public class Block {
}
public Block(@NotNull String[] source, int start, int end) {
if (start < 0 || end > source.length || end < start) {
LOG.error("Invalid block range: [" + start + ", " + end + "); length - " + source.length);
}
mySource = source;
myStart = start;
myEnd = end;
myStart = Math.min(Math.max(0, start), source.length);
myEnd = Math.min(Math.max(myStart, end), source.length);
}
@NotNull
@@ -80,6 +76,10 @@ public class Block {
if (start == -1) start = myStart - shift;
if (end == -1) end = myEnd - shift;
if (start < 0 || end > prevContent.length || end < start) {
LOG.error("Invalid block range: [" + start + ", " + end + "); length - " + prevContent.length);
}
return new Block(prevContent, start, end);
}