How can I refactor C++ source code using emacs?

前端 未结 9 795
孤独总比滥情好
孤独总比滥情好 2021-01-30 06:34

I\'m interested mostly in C++ and method/class name/signature automatic changes.

9条回答
  •  情话喂你
    2021-01-30 07:25

    I've been using cquery for my C++ completion which uses Microsoft LSP for IDE <-> Tool communication. cquery server satisfies the requests of the LSP protocol using a clang backend.

    lsp-emacs is the package that sits between emacs and the cquery backend (cquery-emacs) which exposes an lsp-rename function. As a completion system, cquery has been very reliable and fast by the way, highly recommended.

    Give it a try, follow the getting-started guide on the cquery github: https://github.com/cquery-project/cquery/wiki/Emacs

    Once you've got cquery setup:

    1. Hover your cursor over an identifier (class, var, whatever) you'd like to rename.
    2. M-x lsp-rename
    3. Enter the new name for the identifier.
    4. Do C-x s (save some buffers), which will prompt you to save all the buffers that were touched by the refactor.

    You should probably go through all modified buffers and check what was done after refactoring with any tool/language.

提交回复
热议问题