Class CompoundSourcePositionImpl
java.lang.Object
spoon.support.reflect.cu.position.SourcePositionImpl
spoon.support.reflect.cu.position.CompoundSourcePositionImpl
- All Implemented Interfaces:
Serializable
,CompoundSourcePosition
,SourcePosition
- Direct Known Subclasses:
DeclarationSourcePositionImpl
public class CompoundSourcePositionImpl
extends SourcePositionImpl
implements CompoundSourcePosition
This class represents the position of a named Java program element in a source
file.
- See Also:
- Serialized Form
-
Field Summary
Fields inherited from interface spoon.reflect.cu.SourcePosition
NOPOSITION
-
Constructor Summary
ConstructorDescriptionCompoundSourcePositionImpl(CompilationUnit compilationUnit, int nameStart, int nameEnd, int declarationSourceStart, int declarationSourceEnd, int[] lineSeparatorPositions)
-
Method Summary
Modifier and TypeMethodDescriptionint
returns the end of everything incl.int
returns the start of everything incl.int
Gets the end column in the source file (1 indexed).int
Gets the end line in the source file (1 indexed).int
returns the end of name (int bar = 0 ➡ pos('r'))int
returns the start of name (int foo = 0 ➡ pos('f'))Helper for debugging purposes.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.Methods inherited from class spoon.support.reflect.cu.position.SourcePositionImpl
checkArgsAreAscending, equals, getColumn, getCompilationUnit, getFile, getFragment, getLine, hashCode, isValidPosition, searchColumnNumber, searchLineNumber, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface spoon.reflect.cu.SourcePosition
getColumn, getCompilationUnit, getFile, getLine, isValidPosition, toString
-
Constructor Details
-
CompoundSourcePositionImpl
public CompoundSourcePositionImpl(CompilationUnit compilationUnit, int nameStart, int nameEnd, int declarationSourceStart, int declarationSourceEnd, int[] lineSeparatorPositions)
-
-
Method Details
-
getDeclarationEnd
public int getDeclarationEnd()Description copied from interface:CompoundSourcePosition
returns the end of everything incl. type, name and default value- Specified by:
getDeclarationEnd
in interfaceCompoundSourcePosition
-
getDeclarationStart
public int getDeclarationStart()Description copied from interface:CompoundSourcePosition
returns the start of everything incl. type, name and default value- Specified by:
getDeclarationStart
in interfaceCompoundSourcePosition
-
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
- Overrides:
getSourceEnd
in classSourcePositionImpl
-
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
- Overrides:
getSourceStart
in classSourcePositionImpl
-
getNameStart
public int getNameStart()Description copied from interface:CompoundSourcePosition
returns the start of name (int foo = 0 ➡ pos('f'))- Specified by:
getNameStart
in interfaceCompoundSourcePosition
-
getNameEnd
public int getNameEnd()Description copied from interface:CompoundSourcePosition
returns the end of name (int bar = 0 ➡ pos('r'))- Specified by:
getNameEnd
in interfaceCompoundSourcePosition
-
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
- Overrides:
getEndLine
in classSourcePositionImpl
-
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
- Overrides:
getEndColumn
in classSourcePositionImpl
-
getSourceDetails
Description copied from class:SourcePositionImpl
Helper for debugging purposes. Displays |startIndex; endIndex|sourceCode| of thisSourcePosition
If this instance isDeclarationSourcePosition
orBodyHolderSourcePosition
Then details about name, modifiers and body are included in resulting string too- Overrides:
getSourceDetails
in classSourcePositionImpl
- Returns:
- details about source code of this
SourcePosition
-