This is an archive of the discontinued LLVM Phabricator instance.

[refactor] Add an editor client that is used in clangd
Needs ReviewPublic

Authored by arphaman on Oct 18 2017, 7:10 AM.

Details

Summary

This patch adds an editor client that can do things like:

  • find a list of available refactoring editor commands in a particular range.
  • perform a particular refactoring editor command in a particular range.

This editor client is used in clangd's support for refactoring commands (See dependent revision).

(I've ran out of time to add a unit test before devmeeting, so for now this is tested in clangd, but I'll add a unit test when I update the patch)

Diff Detail

Repository
rL LLVM

Event Timeline

arphaman created this revision.Oct 18 2017, 7:10 AM
ioeric added inline comments.Oct 24 2017, 8:56 AM
include/clang/Tooling/Refactoring/EditorClient.h
46

I think it's worth thinking about how this would work for refactoring actions that touch multiple TUs/ASTs, e.g. renaming symbol references in all user files or adding function definition (in cpp file) from a function declaration (in header file). With the current interfaces, clang-refactor would only be able to work on a single AST, but I think it should be able to get more ASTs from clangd if needed.

The clangd folks (including me) are happy to provide an interface that serves ASTs; we just need to make sure clang-refactor handles multi-TU refactoring. WDYT?

rwols added a subscriber: rwols.Oct 25 2017, 2:23 PM