Class Range
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Does this loosely contain the other range?boolean
Does this loosely contain the other range?boolean
int
int
hashCode()
boolean
boolean
boolean
overlapsWith(Range other)
Does the other 'Range' overlap with this 'Range'?static Range
range(int beginLine, int beginColumn, int endLine, int endColumn)
Create a new `Range` object using the given begin and end line/column values.static Range
Create a new `Range` object using the given begin and end position.boolean
strictlyContains(Position position)
Does this strictly contain position.boolean
strictlyContains(Range other)
Does this strictly contain the other range?toString()
withBeginColumn(int beginColumn)
withBeginLine(int beginLine)
withEndColumn(int endColumn)
withEndLine(int endLine)
-
Field Details
-
begin
-
end
-
-
Constructor Details
-
Range
A range of characters in a source file, from "begin" to "end". This range is inclusive of the characters at the "begin" and "end" positions.Note that if the given parameters are reversed (i.e. the end is earlier than begin, then the values are swapped.
- Parameters:
begin
- The starting position of the range.end
- The end position of the range.
-
-
Method Details
-
range
Create a new `Range` object using the given begin and end position.- Parameters:
begin
- The starting position of the range.end
- The end position of the range.- Returns:
- A new `Range` object with the given start/end position.
-
range
Create a new `Range` object using the given begin and end line/column values. Valid values for each parameter are per the constructor ofPosition
.- Parameters:
beginLine
- The start line of the range.beginColumn
- The start line column of the range.endLine
- The end line of the range.endColumn
- The end column of the range.- Returns:
- A new `Range` object with the given start/end position.
-
withBeginColumn
- Parameters:
beginColumn
- The value used to replace the current begin column number. Valid values are per the constructor ofPosition
.- Returns:
- A copy of this `Range` object, but with the begin column number replaced with the given column number.
-
withBeginLine
- Parameters:
beginLine
- The value used to replace the current begin line number. Valid values are per the constructor ofPosition
.- Returns:
- A copy of this `Range` object, but with the begin line number replaced with the given line number.
-
withEndColumn
- Parameters:
endColumn
- The value used to replace the current end column number. Valid values are per the constructor ofPosition
.- Returns:
- A copy of this `Range` object, but with the end column number replaced with the given line column.
-
withEndLine
- Parameters:
endLine
- The value used to replace the current end line number. Valid values are per the constructor ofPosition
.- Returns:
- A copy of this `Range` object, but with the end line number replaced with the given line number.
-
withBegin
- Parameters:
begin
- The value used to replace the current begin position.- Returns:
- A copy of this `Range` object, but with the begin position replaced with the given position.
-
withEnd
- Parameters:
end
- The value used to replace the current end position.- Returns:
- A copy of this `Range` object, but with the end position replaced with the given position.
-
contains
Does this loosely contain the other range?As
strictlyContains(Range)
, but also allow ranges which have an equal start and/or end position. In these cases, the `other` range is not strictly "inside" of this range. -
contains
Does this loosely contain the other range?As
strictlyContains(Position)
, but a position that is on the "edge" of this range will also pass.For example, if the given position is equal to the start or end position of this range. In these cases, the `other` range is not strictly "inside" of this range.
-
strictlyContains
Does this strictly contain the other range?It means that this has to be larger than other and it has to start before other and end after other.
-
strictlyContains
Does this strictly contain position.It means that the position is after the begin of this range and before the end of this range.
-
overlapsWith
Does the other 'Range' overlap with this 'Range'?If two ranges overlap, this range or the other range contains the begin or the end of the other range.
Note that if the ends are "touching" (i.e. a begin position == end position), this counts as an overlap because the positions refer to characters, as opposed to boundary between characters.
For example, there is an overlap at "C" in the following ranges, with "C" existing within both ranges:
Range 1: ABC Range 2: CDE
-
isBefore
- Parameters:
position
- The position to compare against.- Returns:
- True if the end of this range is before (but not equal to) the given position to compare against.
-
isAfter
- Parameters:
position
- The position to compare against.- Returns:
- True if the start of this range is after (but not equal to) the given position to compare against.
-
equals
-
hashCode
public int hashCode() -
toString
-
getLineCount
public int getLineCount()- Returns:
- The number of lines that this range represents.
If the start line and end line are the same, this range is limited to just one line.
-