Refactoring problems

From: René (renej_no_spam_at_bio.vu.nl)
Date: 01/12/05


Date: 11 Jan 2005 15:59:30 -0800

Hi all,

I wanted to try the refactoring of D2005 pro/update1. The 'extract
method' of worked well, until I started working on one particular unit.
When I tried to use 'extract method' on a piece of code of about 20 lines
within this unit delphi generated an error message (before the extract
method box appears):

"Assertion failed: amount>0, file .\ek_flbuf.cpp, line 233".

No idea what it means, but D2005 crashed after I hit the 'OK' button.
This is not an occasional crash, but it happens every time I try to do an
'extract method' on that particular piece of code (with the same error
message). The code itself, by the way, compiles and runs fine in D2005
before I do any refactoring. It was originally made in D6 pro, so it
probably does not contain any strange characters.

So what is going on here? Well, I figured that maybe the refactoring
engine does not like long lines in the code (which I do tend to make).
After a little experimenting I found the line that caused the error. The
following line of code, written as one single long line with a bunch of
spaces in front of it (22 to be precise) causes the error described
above:

rfjChart1.addstart(1,ylft[i]-(abmp[panel].Height div 2),yrght[i]-(abmp
[panel].Height div 2));

(Wrapping of this line is caused by my xnews editor).

If, however, I break it up into three pieces like this:

rfjChart1.addstart(1,
                   ylft[i]-(abmp[panel].Height div 2),
                   yrght[i]-(abmp[panel].Height div 2));

then everything is fine and the refactoring works. No error, no crash.

So, does D2005 not like long lines? Well, I tested this by putting a few
nested for/next loops one really long line (looks terrible!), but that
did not cause any error. So I have no idea what is going on, but if you
get errors while refactoring, try to change the layout of the code is my
advice.

René