java.lang.Object
com.intellij.openapi.util.TextRange
- All Implemented Interfaces:
Segment,Serializable
A text range defined by start and end (exclusive) offset.
- See Also:
-
Field Summary
FieldsFields inherited from interface com.intellij.openapi.util.Segment
BY_START_OFFSET_THEN_END_OFFSET -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull TextRangestatic booleanareSegmentsEqual(@NotNull Segment segment1, @NotNull Segment segment2) static voidassertProperRange(int startOffset, int endOffset, @NotNull Object message) static voidassertProperRange(@NotNull Segment range) static voidassertProperRange(@NotNull Segment range, @NotNull Object message) booleancontains(int offset) Checks if the given offset is contained within the range (unlikecontainsOffset(int), offset at the end of the range is considered to be outside).booleanChecks if the given segment is fully contained within this TextRange.booleanChecks if the specified text range is fully contained within this TextRange.booleancontainsOffset(int offset) Checks if the given offset is contained within the range (unlikecontains(int), offset at the end of the range is considered to be inside).booleancontainsRange(int startOffset, int endOffset) Checks if the given range is fully contained within this TextRange.static booleancontainsRange(@NotNull Segment outer, @NotNull Segment inner) static @NotNull TextRangecreate(int startOffset, int endOffset) static @NotNull TextRange@NotNull TextRangebooleanbooleanequalsToRange(int startOffset, int endOffset) static @NotNull TextRangefrom(int offset, int length) final intfinal intfinal int@NotNull TextRangegrown(int lengthDelta) inthashCode()intersection(@NotNull TextRange range) booleanintersects(int startOffset, int endOffset) booleanintersects(@NotNull Segment textRange) booleanintersects(@NotNull TextRange textRange) booleanintersectsStrict(int startOffset, int endOffset) booleanintersectsStrict(@NotNull TextRange textRange) booleanisEmpty()static booleanisProperRange(int startOffset, int endOffset) @NotNull String@NotNull TextRangeshiftLeft(int delta) @NotNull TextRangeshiftRight(int delta) @NotNull CharSequencesubSequence(@NotNull CharSequence str) @NotNull StringReturns a substring of the given string that is covered by this TextRange.toString()@NotNull TextRange
-
Field Details
-
EMPTY_RANGE
-
EMPTY_ARRAY
-
-
Constructor Details
-
TextRange
@Contract(pure=true) public TextRange(int startOffset, int endOffset) - See Also:
-
TextRange
protected TextRange(int startOffset, int endOffset, boolean checkForProperTextRange) - Parameters:
checkForProperTextRange-trueif offsets should be checked byassertProperRange(int, int, Object)- See Also:
-
-
Method Details
-
getStartOffset
public final int getStartOffset()- Specified by:
getStartOffsetin interfaceSegment
-
getEndOffset
public final int getEndOffset()- Specified by:
getEndOffsetin interfaceSegment
-
getLength
public final int getLength() -
equals
-
hashCode
public int hashCode() -
contains
Checks if the specified text range is fully contained within this TextRange.- Parameters:
range- the text range to check for containment- Returns:
trueif the specified text range is contained within this object,falseotherwise
-
contains
Checks if the given segment is fully contained within this TextRange.- Parameters:
segment- the segment to be checked for containment- Returns:
- true if the given range is contained within this segment, false otherwise
-
containsRange
@Contract(pure=true) public boolean containsRange(int startOffset, int endOffset) Checks if the given range is fully contained within this TextRange.- Parameters:
startOffset- the start offset of the range to checkendOffset- the end offset of the range to check- Returns:
- true if the given range is contained within this TextRange, false otherwise
-
containsRange
-
containsOffset
@Contract(pure=true) public boolean containsOffset(int offset) Checks if the given offset is contained within the range (unlikecontains(int), offset at the end of the range is considered to be inside).- Parameters:
offset- the offset to check- Returns:
- true if the given offset is within the range, false otherwise
- See Also:
-
toString
-
contains
@Contract(pure=true) public boolean contains(int offset) Checks if the given offset is contained within the range (unlikecontainsOffset(int), offset at the end of the range is considered to be outside).- Parameters:
offset- the offset to check- Returns:
- true if the given offset is within the range, false otherwise
- See Also:
-
substring
Returns a substring of the given string that is covered by this TextRange.- Parameters:
str- the string from which the substring will be extracted- Returns:
- the substring
-
subSequence
@Contract(pure=true) @NotNull public @NotNull CharSequence subSequence(@NotNull @NotNull CharSequence str) -
cutOut
-
shiftRight
-
shiftLeft
-
grown
-
from
-
create
@Contract(pure=true) @NotNull public static @NotNull TextRange create(int startOffset, int endOffset) -
create
-
areSegmentsEqual
-
replace
-
intersects
-
intersects
-
intersects
@Contract(pure=true) public boolean intersects(int startOffset, int endOffset) -
intersectsStrict
-
intersectsStrict
@Contract(pure=true) public boolean intersectsStrict(int startOffset, int endOffset) -
intersection
-
isEmpty
@Contract(pure=true) public boolean isEmpty() -
union
-
equalsToRange
@Contract(pure=true) public boolean equalsToRange(int startOffset, int endOffset) -
allOf
-
assertProperRange
- Throws:
AssertionError
-
assertProperRange
public static void assertProperRange(@NotNull @NotNull Segment range, @NotNull @NotNull Object message) throws AssertionError - Throws:
AssertionError
-
assertProperRange
public static void assertProperRange(int startOffset, int endOffset, @NotNull @NotNull Object message) -
isProperRange
public static boolean isProperRange(int startOffset, int endOffset)
-