Rename backing variable when renaming Getter/Setter #5566
Labels
enhancement
Feature requests, or enhancements to existing features. Ideas. Anything within the project's scope.
feature-refactorings
refactoring-rename
Justification
Often, the backing variable of a Getter will have the same name as the method itself with the backing variable a member of a private type defined within the class. When renaming, it would be time efficient to do one rename/reparse to get both updated.
When renaming the Getter, the corresponding Setter/Letter is automatically renamed, so this would be an additional time savings/convenience.
Description
Using
Refactor|Rename
on aPublic Property Get...
, would cause the Duck to look at the line(s) assigning a value to the property name. If the backing variable (as a member of aPrivate Type
) matches the name of thePublic Property
being "got", the backing variable name would be updated to match.This could be a user configurable option, but I'd imagine that most people who use the
Private Type
method to make the backing variable names match the Getter/Setter names would want to keep them in sync, so that may be overkillAdditional context
An example:
Put the cursor on
Bar()
and selectRefactor|Rename
. TypeSnafu
into the dialog box. Resulting code would be:Put the cursor on
Biff()
and selectRefactor|Rename
. TypeBaz
into the dialog box. Resulting code would be:I know there's no need in this contrived example for the
biff
\baz
backing variable, just roll with it.Having it fix up the casing (as I've done) would be an awesome bonus, but that's simple enough to do by hand if necessary. Having the casing defined in RD options settings would be excellent, but that's probably a whole different feature request that this could take advantage of once it's defined.
The text was updated successfully, but these errors were encountered: