[clangd] Add support to extract method for ExtractFunction Tweak
authorFabio Rossini Sluzala <fabio3rs@gmail.com>
Tue, 5 Apr 2022 17:08:34 +0000 (19:08 +0200)
committerSam McCall <sam.mccall@gmail.com>
Tue, 5 Apr 2022 17:49:17 +0000 (19:49 +0200)
commita0e4ba4b4607267d96c3ab8bc1c38f5a09830692
treeae6dd9a23448bd056fbed8758022cb4ac7096743
parentc082ca16f123144072afffaa21742238021eae9c
[clangd] Add support to extract method for ExtractFunction Tweak

I miss more automatically refactoring functions when working with already running code, so I am making some small addition that I hope help more people.

This works by checking if the function is a method (CXXMethodDecl), then collecting information about the function that the code is being extracted, looking for the declaration if it is out-of-line, creating the declaration if it is necessary and putting the extracted function as a class-method.

This is my first code review request, sorry if I did something wrong.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D122698
clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp