public class SourcePositions
extends java.lang.Object
Constructor and Description |
---|
SourcePositions(java.util.List<IToken> tokenList,
java.util.Map<PositionedNode,SourcecodeRange> positions) |
Modifier and Type | Method and Description |
---|---|
int |
getBeginColumn(PositionedNode node)
Returns the column of the first character of this
PositionedNode ,
i.e. |
int |
getBeginColumn(SourcecodeRange range) |
int |
getBeginLine(PositionedNode node)
Returns the line in which this
PositionedNode begins. |
int |
getBeginLine(SourcecodeRange range) |
int |
getEndColumn(PositionedNode node)
Returns the last column of this
PositionedNode , i.e. |
int |
getEndLine(PositionedNode node)
Returns the line in which the
PositionedNode ends. |
java.lang.String |
getNodeString(PositionedNode node) |
java.lang.String |
getRangeString(SourcecodeRange range) |
SourcecodeRange |
getSourcecodeRange(PositionedNode node)
|
PositionedNode |
getSurroundingNode(int index) |
int |
getTokenforPosition(int line,
int column)
Finds the index of the token that belongs to the position.
|
java.util.List<IToken> |
getTokenList() |
IToken[] |
getTokens(PositionedNode node)
Returns the array of
IToken s belonging to this
PositionedNode . |
void |
replaceMapping(PositionedNode origNode,
PositionedNode newNode) |
public SourcePositions(java.util.List<IToken> tokenList, java.util.Map<PositionedNode,SourcecodeRange> positions)
public SourcecodeRange getSourcecodeRange(PositionedNode node)
node
- the node with source code informationnode
public int getBeginLine(PositionedNode node)
PositionedNode
begins. The value
0
is returned if no sourcecode range is available for this
PositionedNode
.node
- the node with source code informationnode
startspublic int getBeginLine(SourcecodeRange range)
public int getBeginColumn(PositionedNode node)
PositionedNode
,
i.e. the begin column. The value 0
is returned if no
sourcecode range is available for this PositionedNode
.node
- the node with source code informationnode
public int getBeginColumn(SourcecodeRange range)
public int getEndLine(PositionedNode node)
PositionedNode
ends. The value
0
is returned if no sourcecode range is available for this
PositionedNode
.node
- the node with source code informationnode
public int getEndColumn(PositionedNode node)
PositionedNode
, i.e. the column
of the last character of the PositionedNode
. The value
0
is returned if no sourcecode range is available for this
PositionedNode
.node
- the node with source code informationnode
public IToken[] getTokens(PositionedNode node)
IToken
s belonging to this
PositionedNode
. The array may be empty, if no sourcecode range
can be determined for this PositionedNode
.node
- the node with source code informationnode
public java.lang.String getNodeString(PositionedNode node)
public java.lang.String getRangeString(SourcecodeRange range)
public java.util.List<IToken> getTokenList()
public void replaceMapping(PositionedNode origNode, PositionedNode newNode)
public PositionedNode getSurroundingNode(int index)
public int getTokenforPosition(int line, int column)
Finds the index of the token that belongs to the position.
If no token list is available -1
is returned. For
line < 0
the index 0
is returned. If
line >= 1 && column < 0
the line number is returned.
If the line matches but the requested column is beyond the max. length of the line, the last token of this line is returned. The last token of all tokens (EOF) is chosen if the requested positions is beyond the absolutely last token.
Attention: Line and column counting starts at 1!
line
- line of the positioncolumn
- column of the positiontokenList