Review Request 124200: Introduction of rename variable refactoring

Maciej Poleski d82ks8djf82msd83hf8sc02lqb5gh5 at gmail.com
Wed Jul 15 23:03:45 UTC 2015



> On Lip 16, 2015, 12:27 rano, Milian Wolff wrote:
> > can you add a multi-file unit test for this as well?
> > 
> > in general though, I do wonder whether this shows some serious issues with the clang API for refactoring. Renaming a variable based on the data we store in the DUChain cache could be done much quicker. Of course that cache must be up2date, but that's the same for you here... Maybe what we have had in oldcpp (minus the horrible code) wasn't that bad after all. For these "simple" rename refactorings at least, the old architecture could serve us quite well. What I'd be interested in seeing next is other refactorings which we so far never had. Like negating conditionals, putting code into a function, wrapping string literals, ... for that one really needs a proper AST access and probably libTooling. And it's purely local thus does not require all other files to be updated.

I agree. This tool is not breathtaking. But it has its advantage - it showed a few big issues with Clang tooling.
It's vary true - renaming could (and should) be done using cached informations about code. This is different approach (match-and-replace), very expensive...

You are right about these local refactorings, they can be easier to apply (and less expensive) but on the other hand refactoring tools seems to be the one solution to refactor big pieces of code. Everybody can negate conditionals (its tedious, but possible). The other situation is with applying some (small) changes to almost any source file in project. It must be done automatically...
But I see the point, I also noticed that Clang would be much better (to use) at these "local" changes than "whole project". Maybe some arrangements should be changed to see more "local" refactorings instead of some "global" (which concerns almost exclusively refactoring of "interface").

PS I can add more test and will do it. I couldn't add them in this change pack - UTF is "a few" (10?) commits ahead. Tests are coming separately..


- Maciej


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/124200/#review82555
-----------------------------------------------------------


On Lip 14, 2015, 1:44 po południu, Maciej Poleski wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/124200/
> -----------------------------------------------------------
> 
> (Updated Lip 14, 2015, 1:44 po południu)
> 
> 
> Review request for KDevelop.
> 
> 
> Repository: kdev-clang
> 
> 
> Description
> -------
> 
> Introduced rename variable refactoring.
> 
> This patch provides preliminary support for variable rename refactoring.
> Currently only one project is supported.
> Currently it is required to save all opened documents (cache is not ready).
> Regeneration of compile_commands.json needs to be polished. How to get appropriate notification (IProjectBuilder::configured signal)? As a workaround i simply restarted KDevelop to get this regenerated.
> To use this refactoring right click on variable declaration (definition) and select "rename" refactoring.
> 
> 
> Full renaming support will consist of a few parts - one of them is renaming around VarDecl (this patch).
> Quite early, but i wanted to see that this work is going into some direction after month of coding of pure interfaces/details.
> 
> How to split diffs? I noticed that RBTool created diff consisting of all changes ignoring other pending request. I wanted only the last one, because earlier commits are subject of other review.
> 
> NOTE: This is very conservative refactoring. It runs ClangTool on every TU defined in compile_commands.json. Such refactorings are very slow. I will have to work more on it (make some heuristics reducing set of TUs which need processing).
> 
> 
> Diffs
> -----
> 
>   refactoring/utils.cpp PRE-CREATION 
>   refactoring/utils.h PRE-CREATION 
>   refactoring/renamevardeclrefactoring.cpp PRE-CREATION 
>   refactoring/renamevardeclrefactoring.h PRE-CREATION 
>   refactoring/refactoringmanager.cpp PRE-CREATION 
>   refactoring/kdevrefactorings.cpp PRE-CREATION 
>   refactoring/debug.cpp PRE-CREATION 
>   refactoring/debug.h PRE-CREATION 
>   refactoring/CMakeLists.txt PRE-CREATION 
> 
> Diff: https://git.reviewboard.kde.org/r/124200/diff/
> 
> 
> Testing
> -------
> 
> Manual testing on very small code bases as cache and compile_commands.json regeneration is not fully functional.
> 
> 
> Thanks,
> 
> Maciej Poleski
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20150715/98f27849/attachment-0001.html>


More information about the KDevelop-devel mailing list