Does clangd support global rename?

If not, is anyone working on it? How would you implement it? I noticed that Haojian Wu added (local) rename support to clangd in r317780 in November 2017. I CC’d them here in case they know. Thanks :slight_smile:

Hi Michael,

clangd does not yet support global rename and we are not working on it actively at the moment.
We are planning our work for the next quarter right now, we might or might not prioritize it, I’ll update the thread when we have final plans.

On the implementation side, we were discussing using the cross-references information available in clangd.
Following is my personal summary, the final design could end up being be very different from what I describe here.

It is backed the index abstraction, we were discussing if we could base rename on top of the index.
This leads to a design where we would not even need to run the Clang parser on the files when index is up-to-date, therefore getting very good performance.

But this is all very sketchy, our index at the moment:

  1. can be stale and we do not rebuild it during clangd operation (only when clangd starts up),
  2. can miss some references (e.g., if the references are different, depending on the preprocessor context),
  3. may not be enough if we decide to add more features (e.g. conflict detection, etc.).
    Note that current limitations of the index also hurt the quality of cross-references, so they will need to be fixed in any case.

Another alternative is parsing a subset of files that can have references to the symbol and using the AST-based implementation of rename we currently have.
The resulting performance will end up being much slower (parsing C++ is really slow), but we have more freedom to provide a correct and robust implementation.

I would expect the final design to end up a combination of the two (some files could be processed purely using the index, some require AST parsing).