clang-refactoring tool proposal

First, I think clang-refactor is a great idea and a great point of focus for really useful tools.

My proposed solution is to create clang-refactor tool, which would be an
“umbrella” for other refactoring modules. A prototype of clang-refactor
would merge clang-rename inside of it and other modules and refactorings
would be added later.

A properly designed clang-refactor tool would be able to process multiple
Translation Units, which is crucial for all mentioned refactoring.

As a maintainer of a code comprehension tool which uses libclang, it would be really useful if such a refactoring ability was exposed via the higher-level APIs. We’d *love* to have IDE-like refactoring for C/C++/etc. in the tool, and I’m sure our users would too :).

One of the challenges we have with clang-rename, clang-include-fixer etc. is that they are difficult to integrate with existing applications which use libclang. Or perhaps I should say, they require orthogonal integration - currently to integrate these tools, even though I have successfully generated a TU/AST etc., I have to shell out to a binary which users may or may not have installed.

I know that is probably complex to deliver in practice, and I understand that the maintainers may have different opinions on the scope of libclang (or even the scope of this discussion!), but I wanted to throw the idea out there, in case there is appetite. Certainly, I would be super excited to integrate these tools into ycmd/YouCompleteMe. I don’t doubt others would similarly benefit.

I am very excited about the idea of having Clang-based refactoring tool and
I see a lot of potential in it.

Me too! Thanks for the work and ideas.

Cheers,
Ben

I can only second the above. KDevelop is in exactly the same position, and I
bet lots of other tools out there are as well. Just think of the potential
time that can be saved by handing in an existing TU instead of having to parse
that yet again.

Cheers

[Please reply *only* to the list and do not include my email directly
in the To: or Cc: of your reply; otherwise I will not see your reply.
Thanks.]

In article <A44977CF-0922-43D3-92A0-8709287E10B4@gmail.com>,
    Ben Jackson via cfe-dev <cfe-dev@lists.llvm.org> writes:

As a maintainer of a code comprehension tool which uses libclang, it would
be really useful if such a refactoring ability was exposed via the
higher-level APIs. We'd *love* to have IDE-like refactoring for
C/C++/etc. in the tool, and I'm sure our users would too :).

Yes, this an important part for integration into interactive
environments as opposed to batch processing with clang-tidy.

clang-tidy does have an API of sorts -- the individual checks.
However, the overall environment supplied to the checks may be too
clang-tidy workflow specific.

Ben, Milian,

Thank you for the feedback!

Hi,

like everyone else, I think improved refactoring capabilities
in clang would be pretty exciting. This is something I would
really like to work on. So if there's interest to delegate
some chunks of work I'd like to help.

-Alex

Hi everyone!

I’ve just started to search for some open-source project to join because
a) I want to re-learn C++ (there have been a few years since I’ve used it)
b) need some topic for my masters thesis

The tool Kirill proposes sounds like a good opportunity for me to join - as far as I understand, it does not exist yet and there seems to be a community that is interested in using it when it’s done. Do you have any timeline when the planning and development could kick-off? Are there any discussions/docs I should go through first? If you think I should start by doing some bugs in other clang-related projects let me know.

Best regards,

Chris Wisniewski

Hi Alexander and Krzysztof,

Thank you for your interest!

Please find my comment inline.

Hi Kirill,

sounds great. Thanks for being open to contributions!

-Alex

Hey Kirill,

are there any news like design docs or in general more info that you said will appear in the end of this week?

Regards,
Chris Wisniewski

Hi Krzysztof,

Apologies for that, there’s a small delay. Just want to make sure they’re in a good shape before releasing. This is on top of my priority list, so I’ll do that as soon as these docs will be good enough.

-Kirill