Interface SourcePosition

All Superinterfaces:
Serializable
All Known Subinterfaces:
BodyHolderSourcePosition, CompoundSourcePosition, DeclarationSourcePosition
All Known Implementing Classes:
BodyHolderSourcePositionImpl, CompoundSourcePositionImpl, DeclarationSourcePositionImpl, NoSourcePosition, PartialSourcePositionImpl, SourcePositionImpl

public interface SourcePosition extends Serializable
This interface represents the position of a program element in a source file.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets the column in the source file (1 indexed).
    Gets the compilation unit for this position.
    int
    Gets the end column in the source file (1 indexed).
    int
    Gets the end line in the source file (1 indexed).
    Gets the file for this position.
    int
    Gets the line in the source file (1 indexed).
    int
    Gets the index at which the position ends in the source file.
    int
    Gets the index at which the position starts in the source file.
    boolean
     
    Returns a string representation of this position in the form "sourcefile:line", or "sourcefile" if no line number is available.
  • Field Details

  • Method Details

    • isValidPosition

      boolean isValidPosition()
      Returns:
      true if this instance holds start/end indexes of related sources. false if they are unknown
    • toString

      String toString()
      Returns a string representation of this position in the form "sourcefile:line", or "sourcefile" if no line number is available.
      Overrides:
      toString in class Object
    • getFile

      File getFile()
      Gets the file for this position.
    • getCompilationUnit

      CompilationUnit getCompilationUnit()
      Gets the compilation unit for this position.
    • getLine

      int getLine()
      Gets the line in the source file (1 indexed). Prefer using getSourceStart()}. For CtNamedElement the line is where the name is declared.
    • getEndLine

      int getEndLine()
      Gets the end line in the source file (1 indexed). Prefer using getSourceEnd()}.
    • getColumn

      int getColumn()
      Gets the column in the source file (1 indexed). This method is slow because it has to calculate the column number depending on Environment.getTabulationSize() and CtCompilationUnit.getOriginalSourceCode(). Prefer getSourceStart().
    • getEndColumn

      int getEndColumn()
      Gets the end column in the source file (1 indexed). This method is slow because it has to calculate the column number depending on Environment.getTabulationSize() and CtCompilationUnit.getOriginalSourceCode(). Prefer getSourceEnd().
    • getSourceEnd

      int getSourceEnd()
      Gets the index at which the position ends in the source file. Heavily used for the sniper mode.
    • getSourceStart

      int getSourceStart()
      Gets the index at which the position starts in the source file.