问题
I'm using Turbo Explorer 2006 (update 2), and sometimes the IDE crash in a certain unit, specially when I try to use class-completion. The unit (and whole project) are in production and have run fine for years, with daily modifications, it's just the IDE tools that fail.
Usually if this happens, Delphi survives the crash, but some parts of the IDE are defunct (e.g. debug values in tooltips for expressions whose unit is not in the .dpr)
I suspect the parser dies on some specific construct, probably something ifdef'ed, since this unit is an enormous switchboard of systems.
Does sb know specific constructs that kill the IDE? I'd like to fix this so I can use class-completion again.
回答1:
Googling for [ delphi turbo "class completion" crash ] located a bug report with what sounds like the same problem you are seeing. The bug report lists a workaround (»Change "TTest" to "TButton" and remove the "TButton = class(TTest)".«), at least for its given testcase, but I don't know if its applicable in your case.
回答2:
I had some problems with a dynamic multidimensional array:
type
Foo = array of array of Integer;
Code completion and refactoring didn't work, it gave an error about a ; expected somewhere in that declaration, but it compiled just fine.
I fixed it by modifiying the type declaration to this:
type
Foo = array of TIntegerDynArray; //TIntegerDynArray is declared in Types unit
回答3:
The Delphi IDE and (to a lesser extent) compiler are quite fragile. Many non-expected constructs will cause strange problems. So it's not easy to guess off-hand what's the trouble in your case. (The way you describe your unit, I suspect the IFDEF's may play a role though.)
Can't you comment-out parts on the code until the problem disappears, to see whay may causes it ? If your unit is A B C D
, try with
(* A B *) C D
and if that causes no error, try
A B (* C D *)
then perhaps
(* A *) B (* C D *)
etc. until only a small unreducible part of your unit remains. Since you're testing the IDE not the compiler, you probably don't need your commented-out unit to compile without error.
回答4:
{$ifdef something}
type myclass = class
{$else]
type myclass = class(existingclass);
{$endif}
Seems to confuse, but not crash.
Also ifdef in property declarations seems to upset the system.
In D2009,
type myrecord = record someting : set of 0..31; end;
seemed to inhibit completion (it mumbles about SET), but no crash.
update
It is the "set of" construct itself the completion can't handle (while the compiler can)
update 2 : IFDEFs in property declarations also confuse/crash the ide.
来源:https://stackoverflow.com/questions/1057510/known-constructs-that-crash-the-delphi-ide