Rubberduck: Refactor/Rename should include names in within comments.

Created on 27 Sep 2018  路  8Comments  路  Source: rubberduck-vba/Rubberduck

When refactoring the names of variables and procedures, any references to those names in code comments should also be refactored, to prevent creating "comment orphans".

It's common practice to include descriptive comments at the top of a procedure, with explanations of the procedure purpose and its parameters. Also, comments could appear anywhere in code to explain the purpose of any variable. But when RD refactors, it does not change anything in comments. As such, comment orphans are created. It would be great if RD included refactoring of comments to prevent this.

difficulty-02-ducky enhancement feature-refactorings refactoring-rename up-for-grabs

Most helpful comment

If this is implemented, it would absolutely require a preview of all changes in literals and comments. Using meaningful variable names means that the possibility of collisions with actual "words" in comments and strings is increased dramatically.

All 8 comments

I'd extend this to comments and string literals.

If this is implemented, it would absolutely require a preview of all changes in literals and comments. Using meaningful variable names means that the possibility of collisions with actual "words" in comments and strings is increased dramatically.

@comintern beat me to it. Also, a "search comments & string literals" checkbox would be unchecked by default.

Perhaps when words are found in comments, present a simple popup with a Rich Text control that shows a snippet of the code and the found word in bold, with Confirm/Skip buttons..?

at that point there is some minor overlap between the rename refactor and the currently half-shipped regex search and replace. We're trying to (selectively)? Replace($"\\b{oldName}\\b", newName) at this point.

Ohh, I have yet to twiddle with the regex features, even though I use regex regularly in my Access projects.

@spinjector the regex search/replace was written, but a UI was never implemented for it.. it's just sitting there waiting for a UI :wink:

Hmmm... (eyeballs at VS)

Was this page helpful?
0 / 5 - 0 ratings