Package spoon.reflect.cu
Interface SourcePosition
- All Superinterfaces:
Serializable
- All Known Subinterfaces:
BodyHolderSourcePosition
,CompoundSourcePosition
,DeclarationSourcePosition
- All Known Implementing Classes:
BodyHolderSourcePositionImpl
,CompoundSourcePositionImpl
,DeclarationSourcePositionImpl
,NoSourcePosition
,PartialSourcePositionImpl
,SourcePositionImpl
This interface represents the position of a program element in a source file.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
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).getFile()
Gets the file for this position.int
getLine()
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
toString()
Returns a string representation of this position in the form "sourcefile:line", or "sourcefile" if no line number is available.
-
Field Details
-
NOPOSITION
-
-
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. -
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 usinggetSourceStart()
}. For CtNamedElement the line is where the name is declared. -
getEndLine
int getEndLine()Gets the end line in the source file (1 indexed). Prefer usinggetSourceEnd()
}. -
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 onEnvironment.getTabulationSize()
andCtCompilationUnit.getOriginalSourceCode()
. PrefergetSourceStart()
. -
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 onEnvironment.getTabulationSize()
andCtCompilationUnit.getOriginalSourceCode()
. PrefergetSourceEnd()
. -
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.
-