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
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 static SourcePosition
NOPOSITION
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
getColumn()
Gets the column in the source file (1 indexed).CompilationUnit
getCompilationUnit()
Gets the compilation unit for this position.int
getEndColumn()
Gets the end column in the source file (1 indexed).int
getEndLine()
Gets the end line in the source file (1 indexed).File
getFile()
Gets the file for this position.int
getLine()
Gets the line in the source file (1 indexed).int
getSourceEnd()
Gets the index at which the position ends in the source file.int
getSourceStart()
Gets the index at which the position starts in the source file.boolean
isValidPosition()
String
toString()
Returns a string representation of this position in the form "sourcefile:line", or "sourcefile" if no line number is available.
-
-
-
Field Detail
-
NOPOSITION
static final SourcePosition NOPOSITION
-
-
Method Detail
-
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.
-
-