BadLocationException when hovering [message #1061325] |
Fri, 31 May 2013 08:34 |
valentin Mising name Messages: 38 Registered: December 2011 |
Member |
|
|
When mouse hovers over the text
module board();
wire [3:0] count1; // mouse hover between 'c' and 'o' in count1
, TextViewerHoverManager maps x,y location to the offset (it is offset 29 or 30, depending on end-of-line convention) and calls my InformationProvider, which creates a region(offset=30,len=6). Then, manager calls editor.document.getLineOfOffset(region.getOffset()) and getLineOfOffset fails in the TreeLineTracker.lineByOffset().
The code is
int remaining= offset;
Node node= fRoot;
int line= 0;
while (true) {
if (node == null)
fail(offset);
if (remaining < node.offset) {
node= node.left;
} else {
remaining -= node.offset;
line+= node.line;
if (remaining < node.length || remaining == node.length && node.right == null) // last line
return line;
remaining -= node.length;
line ++;
node= node.right;
}
}
I can say that, initially, the remainder is 30 and tracker's node=fRoot is [0+13+2|0|+]. All node.line and and node.offset are 0.
In the first iteration, remainder is decremented by node.length=15, 30->15, and line is incremented by line++, 0->1. The (remaining < node.offset) is never satisfied and right branch is always taken. First right node is [0+13+0|0|=]. It decrements reminder by 13, 15->2 and line is incremented again, 1->2. The next right node happens to be null, causing the BadLocation.
Why?
[Updated on: Fri, 31 May 2013 08:54] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03391 seconds