Lazarus
Miscellaneous => Suggestions => IDE/CodeTools => Topic started by: Rave on March 30, 2013, 07:52:15 am
-
One thing I don't understand is why Lazarus doesn't remove empty methods upon compiling app. Delphi had it since... forever?
For those that may say that it is useful for stubs... Well, I've said *empty* methods. If you will need it later on because it's stub, it should be enough to put comment there in order to it not being removed.
So following method:
procedure Form1.OnClick(Sender:TObject);
begin
end;
would get removed upon compiling application, but following
procedure Form1.OnClick(Sender:TObject);
begin
//stub
end;
or even
procedure Form1.OnClick(Sender:TObject);
begin
//
end;
would not. This is particularly useful for those who missclicked event handler field (instead of double clicking, e.g. Form.OnClick, clicked Form.OnClose and thus made unnecessary method) or those who clicked proper handler, but later on found better solution which made it pointless (and empty).
If you still aren't convinced, it can be always made an option (opt-in or opt-out - I don't care).
-
IDE Options -> Editor -> Completion and Hints -> Auto remove empty methods
-
Oh, didn't know that, thanks!
Locking then.
-
It doesn't seem to work.
Accidentally added wrong event handler so now I have empty method:
procedure Tmain.Image1Click(Sender: TObject);
begin
end;
but IDE doesn't want to remove it, despite selecting option mentioned above.
-
Does it still have the interface in the class definition? i.e.:
Tmain = class(TForm)
...
procedure Image1Click(Sender: TObject);
...
end;
-
I had this same problem today. After I selected the option to automatically remove empty methods, the methods remained. I even re-started the IDE with no change.
I was able to get it to work only after deleting the white space between the begin and end for the method(s). I then created empty methods again to make sure it would remove the methods automatically. The empty methods were removed after I clicked the Save button.
-
Thanks, Jeff. Your solution worked (although restarting IDE wasn't necessary). I think this glitch should be fixed (or was it? I'm still on Laz 1.0 due to later version adding some performance issues with drawing on TCanvas which isn't wanted when developing games).
-
Test on Lazarus v1.1.
- Start empty project.
- Doubleclick on form, and onFormCreate event is created.
- Compile project, onFormCreate event is automatically removed.
-
I had this same problem today. After I selected the option to automatically remove empty methods, the methods remained. I even re-started the IDE with no change.
I was able to get it to work only after deleting the white space between the begin and end for the method(s). I then created empty methods again to make sure it would remove the methods automatically. The empty methods were removed after I clicked the Save button.
Odd. I just tested on 1.1. White spaces are ignored. (I did switch of trim trailing spaces, so I could enter white spaces, that would be kept)
-
IDE Options -> Editor -> Completion and Hints -> Auto remove empty methods
I think it should be checked by default, for a better Delphi compatibility.
Regards
Tintinux
-
This should be ON by default. I have been using Lazarus for months and just thought I have to manually remove them.
-
This should be ON by default. I have been using Lazarus for months and just thought I have to manually remove them.
First of all, responding to a 10 year old thread is frowned upon.
Second: it should of course be OFF by default, this Delphi feature has annoyed me right from Delphi 1.
Just my personal opinon.
Bart