summaryrefslogtreecommitdiff
path: root/platform/util/src/com/intellij/openapi/util/TextRange.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/util/src/com/intellij/openapi/util/TextRange.java')
-rw-r--r--platform/util/src/com/intellij/openapi/util/TextRange.java10
1 files changed, 10 insertions, 0 deletions
diff --git a/platform/util/src/com/intellij/openapi/util/TextRange.java b/platform/util/src/com/intellij/openapi/util/TextRange.java
index 797bc23ee747..4c09b969a570 100644
--- a/platform/util/src/com/intellij/openapi/util/TextRange.java
+++ b/platform/util/src/com/intellij/openapi/util/TextRange.java
@@ -99,6 +99,16 @@ public class TextRange implements Segment, Serializable {
}
@NotNull
+ public CharSequence subSequence(@NotNull CharSequence str) {
+ try {
+ return str.subSequence(myStartOffset, myEndOffset);
+ }
+ catch (IndexOutOfBoundsException e) {
+ throw new IndexOutOfBoundsException("Can't extract " + this + " range from " + str);
+ }
+ }
+
+ @NotNull
public TextRange cutOut(@NotNull TextRange subRange) {
assert subRange.getStartOffset() <= getLength() : subRange + "; this="+this;
assert subRange.getEndOffset() <= getLength() : subRange + "; this="+this;