Dart: rename variable from the server

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:

  1. 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)
  2. DartServerRenameTest: calls the server 'edit.getRefactoring', but I couldn't trigger this from using the plugin as a user
  3. I see DartServerRenameHandler which implements RenameHandler.

 

My questions are:

  1. What does DartServerRenameTest test? Is it testing something not actually happening with the user?
  2. Is DartServerRenameHandler handling something else e.g. file edit? If yes, should we have 'RenamePsiElementProcessor' extension to handle such case?
  3. Any other hints

 

Thanks a lot.

1 comment
Comment actions Permalink
Official 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.

Please sign in to leave a comment.