Home » Eclipse Projects » Eclipse Platform » ContentAssist dilemma--keep getting BadLocationException on an insert
|
Re: ContentAssist dilemma--keep getting BadLocationException on an insert [message #326530 is a reply to message #326528] |
Sat, 22 March 2008 17:31 |
Alex Le Messages: 649 Registered: July 2009 |
Senior Member |
|
|
AL wrote:
> Hi,
>
> I have content assist implemented on my editor.
>
> Say, I start out a very fresh document and type in "ab" then Ctrl+Space
> to activate the content assist. Then I choose a proposal from the list
> and it has the string "foo(a,b)" to insert.
>
> I keep encountering the below exception from the AbstractDocument class.
> the 'pos + length' is always greater than what getLength() returned,
> which is 2, the length of 'ab'. Any tips? Thanks.
>
> public void replace(int pos, int length, String text, long
> modificationStamp) throws BadLocationException {
> if ((0 > pos) || (0 > length) || (pos + length > getLength()))
> throw new BadLocationException();
Just to clarify that my insertion offset is zero, that is, attempting to
replace "ab" with "foo(a,b)".
|
|
| |
Re: ContentAssist dilemma--keep getting BadLocationException on an insert [message #326583 is a reply to message #326559] |
Tue, 25 March 2008 18:03 |
Alex Le Messages: 649 Registered: July 2009 |
Senior Member |
|
|
Daniel Megert wrote:
> AL wrote:
>> Hi,
>>
>> I have content assist implemented on my editor.
>>
>> Say, I start out a very fresh document and type in "ab" then
>> Ctrl+Space to activate the content assist. Then I choose a proposal
>> from the list and it has the string "foo(a,b)" to insert.
> Check that the offsets and lengths in your proposal is correct.
Double-check with debugging sessions, still something is wrong. My
replacement offset is zero, that is, positioning at the 'a' in "ab",
which is to be replaced. My replacement length is 8, which is the
length of "foo(a,b)".
And keep encountering the below exception.
> Dani
>>
>> I keep encountering the below exception from the AbstractDocument class.
>> the 'pos + length' is always greater than what getLength() returned,
>> which is 2, the length of 'ab'. Any tips? Thanks.
>>
>> public void replace(int pos, int length, String text, long
>> modificationStamp) throws BadLocationException {
>> if ((0 > pos) || (0 > length) || (pos + length > getLength()))
>> throw new BadLocationException();
|
|
|
Re: ContentAssist dilemma--keep getting BadLocationException on an insert [message #326635 is a reply to message #326583] |
Thu, 27 March 2008 01:25 |
Alex Le Messages: 649 Registered: July 2009 |
Senior Member |
|
|
AL wrote:
>> Check that the offsets and lengths in your proposal is correct.
>
> Double-check with debugging sessions, still something is wrong. My
> replacement offset is zero, that is, positioning at the 'a' in "ab",
> which is to be replaced. My replacement length is 8, which is the
> length of "foo(a,b)".
>
> And keep encountering the below exception.
>
Dud! the replacement length to use is 2 NOT 8; it's the length of the
text to be replaced by the new text. I had done ContentAssist
before...Somehow misunderstood the parameter description!
:-)
>>> I keep encountering the below exception from the AbstractDocument class.
>>> the 'pos + length' is always greater than what getLength() returned,
>>> which is 2, the length of 'ab'. Any tips? Thanks.
>>>
>>> public void replace(int pos, int length, String text, long
>>> modificationStamp) throws BadLocationException {
>>> if ((0 > pos) || (0 > length) || (pos + length > getLength()))
>>> throw new BadLocationException();
|
|
|
Goto Forum:
Current Time: Sat Nov 09 00:59:21 GMT 2024
Powered by FUDForum. Page generated in 0.03340 seconds
|