Dart: rename variable from the server Follow
Answered
I am trying to make the Dart plugin use the server for renaming a variable, as the IDEA part to fix https://github.com/dart-lang/sdk/issues/47521
The following points are noticed:
- The plugin doesn't call the server, but uses VariableInplaceRenamer (which extends InplaceRefactoring) and uses startTemplate() (in https://github.com/JetBrains/intellij-community/blob/eeac17a4041e0de49aabf848121b474ee17a0a03/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/InplaceRefactoring.java#L371)
- DartServerRenameTest: calls the server 'edit.getRefactoring', but I couldn't trigger this from using the plugin as a user
- I see DartServerRenameHandler which implements RenameHandler.
My questions are:
- What does DartServerRenameTest test? Is it testing something not actually happening with the user?
- Is DartServerRenameHandler handling something else e.g. file edit? If yes, should we have 'RenamePsiElementProcessor' extension to handle such case?
- Any other hints
Thanks a lot.
Please sign in to leave a comment.
Sorry for delay, I was on vacation.
Local variables are renamed in-place. That's true, Dart plugin doesn't call edit.getRefactoring in this case. It uses navigation data (references) instead, which have been already received from server at the moment of renaming.
DartServerRenameTest tests DartServerRenameHandler. DartServerRenameHandler works for renaming other stuff: fields, classes, etc.
It's easy to make local variables rename go through DartServerRenameHandler as well. But DartServerRenameHandler current implementation shows a modal dialog. At JetBrains, we try to run refactorings in-place where possible. So it wouldn't be great to loose in-place local var renaming.
I guess it's possible to make DartServerRenameHandler work in-place, without a dialog, and I plan to do so eventually, but no certain ETA.