Forum > IDE/CodeTools

Removing empty methods

(1/3) > >>

Rave:
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:

--- Code: ---procedure Form1.OnClick(Sender:TObject);
begin

end;
--- End code ---

would get removed upon compiling application, but following

--- Code: ---procedure Form1.OnClick(Sender:TObject);
begin
//stub
end;
--- End code ---

or even


--- Code: ---procedure Form1.OnClick(Sender:TObject);
begin
//
end;
--- End code ---
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).

JuhaManninen:
IDE Options -> Editor -> Completion and Hints -> Auto remove empty methods

Rave:
Oh, didn't know that, thanks!
Locking then.

Rave:
It doesn't seem to work.

Accidentally added wrong event handler so now I have empty method:

--- Code: ---procedure Tmain.Image1Click(Sender: TObject);
begin

end;
--- End code ---

but IDE doesn't want to remove it, despite selecting option mentioned above.

Leledumbo:
Does it still have the interface in the class definition? i.e.:

--- Quote ---Tmain = class(TForm)
...
procedure Image1Click(Sender: TObject);
...
end;

--- End quote ---

Navigation

[0] Message Index

[#] Next page

Go to full version