Refactoring C++

In preparation for a demo I’m giving soon, I’ve been playing more
with the new CDT release. I think the biggest change is
support for refactoring. In my little experiments I was able to
rename classes, macros, methods (though I haven’t tried virtual methods
yet), functions, and variables. Pretty cool!

The way this works under the hood is that they have a C and C++
parser written in java (which understands GNU extensions as well).
Renames are handled by using the parser’s AST to find the appropriate
locations to modify. This way they don’t end up renaming in places
that use the same name but which refer to different objects.

I suppose they wrote their own parser for the classic reasons:
the perennial favorite, license problems; and the fact that the GCC
parsers aren’t exactly reusable. In Java, pretty much everybody
writes their programs as reusable libraries. In C, pretty much
nobody does.

Be the first to leave a comment. Don’t be shy.

Join the Discussion

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.