[PATCH] D65263: [clangd] a prototype for triggering rename after extracting.

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 25 06:34:21 PDT 2019


ilya-biryukov added a comment.

If we are going down that path, could we consider to pre-selecting a name of the extract variable and its usage (using multi-select)?
I.e. the optimal workflow seems to be (`[[code]] marks selected regions`):

  // Input:
  foo([[10+10]]);
  
  
  // 'extract' turns this into the following code (and selects for editors that support this):
  int [[dummy]] = 10+10;
  foo([[dummy]]);

At this point users can type a new name and get it updated directly.
There are a bunch of reasons why running the full-blown rename is suboptimal:

- rename can fail, e.g. if you had other variables called `dummy` in this scope or if we actions happen to produce broken AST,
- rename UI is generally clunkier than multi-selection (a new window is opened, this moves focus from the code to the editor).
- rename has to wait for the AST, in general case this might result in high latency for actions that can add an `#include` or if we any of the included files changed.

The obvious drawback is that this workflow might be hard to implement in some editors, but both Vim and VSCode should be able to provide a decent experience here.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65263/new/

https://reviews.llvm.org/D65263





More information about the cfe-commits mailing list