public class SourcePositionImpl extends java.lang.Object implements SourcePosition, java.io.Serializable
NOPOSITION
Constructor and Description |
---|
SourcePositionImpl(CompilationUnit compilationUnit,
int sourceStart,
int sourceEnd,
int[] lineSeparatorPositions) |
Modifier and Type | Method and Description |
---|---|
protected static void |
checkArgsAreAscending(int... values)
fails when `values` are not sorted ascending
It is used to check whether start/end values of SourcePosition are consistent
|
boolean |
equals(java.lang.Object obj) |
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).
|
java.io.File |
getFile()
Gets the file for this position.
|
protected java.lang.String |
getFragment(int start,
int end) |
int |
getLine()
Gets the line in the source file (1 indexed).
|
java.lang.String |
getSourceDetails()
Helper for debugging purposes.
|
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.
|
int |
hashCode() |
boolean |
isValidPosition() |
protected int |
searchColumnNumber(int position)
Search the column number
|
protected int |
searchLineNumber(int position)
Search the line number corresponding to a specific position
|
java.lang.String |
toString()
Returns a string representation of this position in the form
"sourcefile:line", or "sourcefile" if no line number is available.
|
public SourcePositionImpl(CompilationUnit compilationUnit, int sourceStart, int sourceEnd, int[] lineSeparatorPositions)
protected int searchLineNumber(int position)
protected int searchColumnNumber(int position)
public boolean isValidPosition()
isValidPosition
in interface SourcePosition
public int getColumn()
SourcePosition
Environment.getTabulationSize()
and
CtCompilationUnit.getOriginalSourceCode()
. Prefer SourcePosition.getSourceStart()
.getColumn
in interface SourcePosition
public int getEndColumn()
SourcePosition
Environment.getTabulationSize()
and
CtCompilationUnit.getOriginalSourceCode()
. Prefer SourcePosition.getSourceEnd()
.getEndColumn
in interface SourcePosition
public java.io.File getFile()
SourcePosition
getFile
in interface SourcePosition
public int getLine()
SourcePosition
SourcePosition.getSourceStart()
}.
For CtNamedElement the line is where the name is declared.getLine
in interface SourcePosition
public int getEndLine()
SourcePosition
SourcePosition.getSourceEnd()
}.getEndLine
in interface SourcePosition
public int getSourceEnd()
SourcePosition
getSourceEnd
in interface SourcePosition
public int getSourceStart()
SourcePosition
getSourceStart
in interface SourcePosition
public java.lang.String toString()
toString
in interface SourcePosition
toString
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public CompilationUnit getCompilationUnit()
SourcePosition
getCompilationUnit
in interface SourcePosition
public java.lang.String getSourceDetails()
SourcePosition
If this instance is DeclarationSourcePosition
or BodyHolderSourcePosition
Then details about name, modifiers and body are included in resulting string tooSourcePosition
protected java.lang.String getFragment(int start, int end)
protected static void checkArgsAreAscending(int... values)
Copyright © 2007–2021 Inria. All rights reserved.