Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tool to refactor "with" blocks

Is there a refactoring tool to remove "with" blocks? For example convert

with Form1 do
begin
  Height := Blah;
  Blubb := Name;
end;

to

Form1.Height := Blah;
Blubb := Form1.Name;

where Form1 is a VCL TForm. Optimally it should work with Delphi 2007.

like image 539
Uli Gerhardt Avatar asked Feb 15 '12 10:02

Uli Gerhardt


People also ask

What is a refactoring tool?

Code refactoring is a controller technique or process of restructuring your code without changing its external behavior for easier maintenance, better readability, understanding, and extended support. The main purpose of refactoring is to fight technical debt.

Does PyCharm refactor?

Do one of the following: On the main Refactor menu or from the context menu of the selection, choose the desired refactoring or press the corresponding keyboard shortcut (if any). From the main menu, choose Refactor | Refactor This, or press Ctrl+Alt+Shift+T , and then select the desired refactoring from the popup.


2 Answers

Model Maker Code Explorer, which became free recently, has "Convert with statement" tool. While it is not a fully automated refactoring, it might be useful, if Castalia does not work

like image 61
Serhii Kheilyk Avatar answered Oct 25 '22 03:10

Serhii Kheilyk


One of the Castalia refactoring tools is named "Eliminate 'WITH'".

I can't comment on how well it works in non trivial code because I tend to avoid "with".

like image 37
Bruce McGee Avatar answered Oct 25 '22 03:10

Bruce McGee