Package spoon.reflect.cu.position
Class NoSourcePosition
- java.lang.Object
-
- spoon.reflect.cu.position.NoSourcePosition
-
- All Implemented Interfaces:
Serializable
,SourcePosition
- Direct Known Subclasses:
PartialSourcePositionImpl
public class NoSourcePosition extends Object implements SourcePosition
This class represents the position of a program element in a source file.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
NoSourcePosition.NullCompilationUnit
-
Field Summary
-
Fields inherited from interface spoon.reflect.cu.SourcePosition
NOPOSITION
-
-
Constructor Summary
Constructors Constructor Description NoSourcePosition()
-
Method Summary
All Methods Instance Methods Concrete 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.
-
-
-
Method Detail
-
getFile
public File getFile()
Description copied from interface:SourcePosition
Gets the file for this position.- Specified by:
getFile
in interfaceSourcePosition
-
getCompilationUnit
public CompilationUnit getCompilationUnit()
Description copied from interface:SourcePosition
Gets the compilation unit for this position.- Specified by:
getCompilationUnit
in interfaceSourcePosition
-
isValidPosition
public boolean isValidPosition()
- Specified by:
isValidPosition
in interfaceSourcePosition
- Returns:
- true if this instance holds start/end indexes of related sources. false if they are unknown
-
getLine
public int getLine()
Description copied from interface:SourcePosition
Gets the line in the source file (1 indexed). Prefer usingSourcePosition.getSourceStart()
}. For CtNamedElement the line is where the name is declared.- Specified by:
getLine
in interfaceSourcePosition
-
getEndLine
public int getEndLine()
Description copied from interface:SourcePosition
Gets the end line in the source file (1 indexed). Prefer usingSourcePosition.getSourceEnd()
}.- Specified by:
getEndLine
in interfaceSourcePosition
-
getColumn
public int getColumn()
Description copied from interface:SourcePosition
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()
. PreferSourcePosition.getSourceStart()
.- Specified by:
getColumn
in interfaceSourcePosition
-
getEndColumn
public int getEndColumn()
Description copied from interface:SourcePosition
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()
. PreferSourcePosition.getSourceEnd()
.- Specified by:
getEndColumn
in interfaceSourcePosition
-
getSourceEnd
public int getSourceEnd()
Description copied from interface:SourcePosition
Gets the index at which the position ends in the source file. Heavily used for the sniper mode.- Specified by:
getSourceEnd
in interfaceSourcePosition
-
getSourceStart
public int getSourceStart()
Description copied from interface:SourcePosition
Gets the index at which the position starts in the source file.- Specified by:
getSourceStart
in interfaceSourcePosition
-
toString
public String toString()
Description copied from interface:SourcePosition
Returns a string representation of this position in the form "sourcefile:line", or "sourcefile" if no line number is available.- Specified by:
toString
in interfaceSourcePosition
- Overrides:
toString
in classObject
-
-