Known constructs that crash the Delphi IDE

倾然丶 夕夏残阳落幕 提交于 2019-12-08 05:27:00

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!