R# plugins - is it possible to inject custom values into "Introduce variable" and similar refactorings?


I'd like to add more items into introduce variable list of options. Example: Mock<IMyClass> -> myClass. I can see such functionality working for generalized classes like List, but not sure how to plug in my own logic.


Do you mean suggesting the name of a new variable? Unfortunately, the rules to suggest names are not directly extensible. However, you could probably create a new code completion items provider that could add items at the same time as the variable name suggestions, and they'll get merged in. You can take a look at NameSuggestionRule in dotPeek to see when it's available, and what it adds.


I've just added a feature request you can vote for and track: https://youtrack.jetbrains.com/issue/RSRP-439189


Please sign in to leave a comment.