Interface LocationCapable

All Known Subinterfaces:
EnumConstantSource.Body, FieldSource<O>, JavaAnnotationSource, JavaClassSource, JavaEnumSource, JavaInterfaceSource, JavaPackageInfoSource, JavaRecordSource, JavaSource<T>, MemberSource<O,T>, MethodSource<O>

public interface LocationCapable
Provides location information about an element in the source file
Author:
George Gastaldi
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the column number corresponding to the given source character position in the original source string.
    int
    Returns the character index into the original source file indicating where the source fragment corresponding to this element ends.
    int
    Returns the line number corresponding to the given source character position in the original source string.
    int
    Returns the character index into the original source file indicating where the source fragment corresponding to this element begins.
  • Method Details

    • getStartPosition

      int getStartPosition()
      Returns the character index into the original source file indicating where the source fragment corresponding to this element begins.
      Returns:
      the 0-based character index, or -1 if no source position information is recorded for this element
    • getEndPosition

      int getEndPosition()
      Returns the character index into the original source file indicating where the source fragment corresponding to this element ends.
      Returns:
      the 0-based character index, or -1 if no source position information is recorded for this element
    • getLineNumber

      int getLineNumber()
      Returns the line number corresponding to the given source character position in the original source string. The initial line of the compilation unit is numbered 1, and each line extends through the last character of the end-of-line delimiter. The very last line extends through the end of the source string and has no line delimiter. For example, the source string class A\n{\n} has 3 lines corresponding to inclusive character ranges [0,7], [8,9], and [10,10]. Returns -1 for a character position that does not correspond to any source line, or -2 if no line number information is available for this compilation unit.
      Returns:
      the 1-based line number, or -1 if the character position does not correspond to a source line in the original source file or -2 if line number information is not known for this compilation unit
    • getColumnNumber

      int getColumnNumber()
      Returns the column number corresponding to the given source character position in the original source string. Column number are zero-based. Return -1 if it is beyond the valid range or -2 if the column number information is unknown.
      Returns:
      the 0-based column number, or -1 if the character position does not correspond to a source line in the original source file or -2 if column number information is unknown for this compilation unit