Package org.eclipse.jdt.core
Class SourceRange
java.lang.Object
org.eclipse.jdt.core.SourceRange
- All Implemented Interfaces:
ISourceRange
A source range defines an element's source coordinates relative to
its source buffer.
- Since:
- 3.6
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSourceRange(int offset, int length) Instantiate a new source range using the given offset and the given length. -
Method Summary
Modifier and TypeMethodDescriptionbooleanintReturns the number of characters of the source code for this element, relative to the source buffer in which this element is contained.intReturns the 0-based index of the first character of the source code for this element, relative to the source buffer in which this element is contained.inthashCode()static booleanisAvailable(ISourceRange range) Helper method that answers whether a valid source range is available in the given ISourceRange.toString()
-
Constructor Details
-
SourceRange
public SourceRange(int offset, int length) Instantiate a new source range using the given offset and the given length.- Parameters:
offset- the given offsetlength- the given length
-
-
Method Details
-
isAvailable
Helper method that answers whether a valid source range is available in the given ISourceRange. When an element has no associated source code, Java Model APIs may return eithernullor a range of [-1, 0] to indicate an invalid range. This utility method can be used to detect that case.- Parameters:
range- a source range, can benull- Returns:
trueiff range is not null and range.getOffset() is not -1
-
equals
-
getLength
public int getLength()Description copied from interface:ISourceRangeReturns the number of characters of the source code for this element, relative to the source buffer in which this element is contained.- Specified by:
getLengthin interfaceISourceRange- Returns:
- the number of characters of the source code for this element, relative to the source buffer in which this element is contained
- See Also:
-
getOffset
public int getOffset()Description copied from interface:ISourceRangeReturns the 0-based index of the first character of the source code for this element, relative to the source buffer in which this element is contained. However, if the element has no associated source code, an implementation may return -1.- Specified by:
getOffsetin interfaceISourceRange- Returns:
- the 0-based index of the first character of the source code for this element, relative to the source buffer in which this element is contained. However, if the element has no associated source code, an implementation may return -1.
- See Also:
-
hashCode
public int hashCode() -
toString
-