Recent

Author Topic: [SOLVED] Is this the normal behaviour of Refactoring --> Empty Methods?  (Read 2220 times)

lazjump

  • Jr. Member
  • **
  • Posts: 61
Hello,

I found something that might not the intended behaviour of Refactoring --> Empty Methods.

Steps to reproduce:
1. Create a new project
2. Put a button on the form
3. Double click the button so the skeleton code for the OnClick event handler will be created
4. Do not write anything inside the event handler
5. Click/position the editor cursor anywhere outside the event handler (for example, between the end; and end.)
6. Right click and choose Refactoring --> Empty Methods...
7. Lazarus will pop up a message like "No class at unit1.pas(36,3)"

If we put the cursor inside the method, then it works normally.
« Last Edit: November 05, 2014, 12:17:37 am by lazjump »
I thought Delphi was expensive until I learned the price of ExtJS

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Is this the normal behaviour of Refactoring --> Empty Methods?
« Reply #1 on: November 04, 2014, 06:58:34 pm »
To find empty methods the IDE needs to know which class(es) to search.
If the cursor is not somewhere inside a class, it seems logical to me that the Remove Empty Methods dialog points out that the user has not identified a class for it to search.

There are at least two other ways of identifying/removing empty methods:

If you open the IDE Options dialog (Tools->Options),
Editor, Completion and Hints, offers Auto-remove empty methods. Any time you rebuild/recompile (perhaps even on Idle, not sure), any empty method(s) will be removed, irrespective of where your cursor is.

Codetools, Code Explorer, Code Observer, offers to identify not only empty class sections but empty procedures and empty blocks. For this functionality it does not matter where your cursor is located.

lazjump

  • Jr. Member
  • **
  • Posts: 61
Re: Is this the normal behaviour of Refactoring --> Empty Methods?
« Reply #2 on: November 05, 2014, 12:17:06 am »
Hi howardpc,

Thank you for your explanations and the tips about two other ways to identify/remove empty methods.
I thought Delphi was expensive until I learned the price of ExtJS

 

TinyPortal © 2005-2018