Jump to content
dmitrybv

Refactor – Rename (Type, Field, Property) Alternatives in Delphi 13

Recommended Posts

In previous versions of Delphi, there was a Refactor → Rename menu for renaming types, fields, and properties across the entire project.

In Delphi 13, this menu seems to be missing.

I tried using MMX Code Explorer, but I couldn't find an equivalent. MMX offers Rename in Scope, but it only works at the unit level and does not rename the identifier throughout the entire project.

Are there any alternatives or tools in Delphi 13 that provide full-project renaming functionality similar to the old Refactor → Rename?

Share this post


Link to post

I've been using dnGrep daily (although any general search and replace tool will suffice) for more than a year, and it has been more than enough for me. It has a wide variety of search features, and it displays the files with ease. I also made a small tool that allows you to open the matching file and jump to the line number in RAD Studio, which made the usage of the tool even better.

 

GExperts also has an awesome grep tool integrated into the IDE, although I got used to dnGrep before I found out about it.

 

The only downside is that trying to rename a public property, method or field might be inconvenient, as other might exist with the same name.

Share this post


Link to post
5 hours ago, dmitrybv said:

MMX offers Rename in Scope, but it only works at the unit level and does not rename the identifier throughout the entire project.

While it wouldn't be a problem to extend the scope to the current project and project group, the outcome may not be what is expected. The removed refactoring used some sort of code model to limit the rename on the actual type, field, property or method. In contrast to MMX renaming using some search and replace action limited to the given scope. That way it is possible to extend the renaming on comments and/or string content - something a code model based rename cannot do.

 

Nevertheless, there exists an epic in the issue tracker to extend the renaming to the project and project group level with respecting the underlying code model. As one might guess, that is quite a big task (hence an epic). As MMX still is a free time project of mine, I cannot give a time frame for implementing this request.

Share this post


Link to post
10 hours ago, Uwe Raabe said:

In contrast to MMX renaming using some search and replace action limited to the given scope.

Doesn't MMX have an AST representing the code?

 

10 hours ago, Uwe Raabe said:

something a code model based rename cannot do.

It also cannot make coffee but who cares as long as it can actually refactor code - based on the code model.

Messing with the comments, when doing a rename, is bound to change texts that wasn't meant to be changed.

Share this post


Link to post
1 hour ago, Anders Melander said:

Doesn't MMX have an AST representing the code?

Unfortunately, it has not. Yet.

Share this post


Link to post
5 hours ago, Uwe Raabe said:

Yet

This gives us some hope.  Delphi users do need decent refactoring.  Let us know if we can help.   This could be a community effort.

Edited by pyscripter

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×