[cfe-dev] RFC: Adding a rename refactoring tool to clang

Richard legalize at xmission.com
Wed Jul 30 12:00:05 PDT 2014


My apologies if this is getting too off-topic for the list.  I'm happy
to continue the conversation in private or on usenet or wherever is
more appropriate.

In article <53D9279E.8080702 at pathscale.com>,
    =?ISO-8859-1?Q?=22C=2E_Bergstr=F6m=22?= <cbergstrom at pathscale.com> writes:

> On 07/30/14 11:42 PM, Richard wrote:
> > This is where clang-based refactoring tools are really going to shine.
> > Leveraging the *production quality* parser and resulting lossless AST
> > just puts you miles ahead in the game.
>
> Have you evaluated MSVC+Visually Assist plugin? While it's not IntelliJ, 
> I have heard good things about it. I think that's a professional level 
> baseline which other tools could work towards matching/beating..

Visual AssistX isn't bad and I use it regularly.  However, it still
has a long way to go as a refactoring tool.  VAX started as improved
IntelliSense and code navigation in VC6 days.  That is still the area
where it primarily excels, but with MS improving code navigation on
their own I think they realized they needed to be more than code
navigation in order to continue gaining customers.  They have added
limited refactoring support in more recent versions.

I posted a review of a recent build here:
<http://legalizeadulthood.wordpress.com/2014/06/13/refactoring-test-results-for-vax-10-8-2036-0-built-2014-05-22/>

Of the different refactoring tools out there that seem interesting, I
need to go look at QtCreator since it has quite a bunch of interesting
refactorings according to it's docs.  When I posted the results linked
above, someone suggested that I look at it.  Some coworkers had been
using it but it supports more refactorings than I was led to believe
from talking with them.  It's on my list to evaluate.

I had previously known about the Eclipse CDT support, but I couldn't
find anyone to recommend and/or champion it as a refactoring tool and
it didn't seem like anyone was actively pushing CDT forward.

It's unfortunate that the different tools use different terminology for
the same transformation.  There are a bunch of refactorings that are
specific to C/C++ for which we could all benefit from using the same
name.  I've written up some of these on my blog over the years:
<http://legalizeadulthood.wordpress.com/category/refactoring/>

In the list below I've tried to choose the same name for the same
operation between tools, but it may not be the name they use in their
own documentation.  I know of the following refactoring tools for C++:

clang-modernize: free tool by some very cool d00dz :-)
	<http://clang.llvm.org/extra/clang-modernize.html>
Refactorings:
	Replace Explicit For Loop with Range For Loop
	Replace 0/NULL with nullptr
	Replace Type Declaration with auto
	Decorate Virtual Methods with override
	Replace Pass by Reference with Pass By Value
	Replace auto_ptr with unique_ptr

Visual AssistX: commercial tool by Whole Tomato.
	<http://wholetomato.com>
Refactorings:
	Rename
	Extract Function/Method
	Move Implementation to/from Source/Header
	Change Signature

CodeRush for Visual Studio: commercial tool by Developer Xpress.
	Discontinued
	<https://www.devexpress.com/Products/CodeRush/cpp11.xml>
Refactorings:
	Supported a bunch, but they were quite buggy (I filed over 300
	bugs and this was the impetus for creating the refactoring tool
	test suite.)

Qt Creator: free tool by Qt project
	<https://qt-project.org/search/tag/qt~creator>
Refactorings:
	<https://qt-project.org/doc/qtcreator-3.0/creator-editor-refactoring.html>
	Rename
	Add Curly Braces
	Move Declaration Out of Condition
	Negate Condition
	Split Declaration
	Split If Statement
	Swap Operands (e.g. a > b becomes b < a)
	Convert Literal to Decimal
	Convert Literal to Hexadecimal
	Convert Literal to Octal
	Convert to ObjectiveC String Literal
	Replace char Literal with QLatin1Char Literal
	Replace C-style String Literal with QLatin1String Literal
	Mark as Translatable
	Reorder Parameters
	Extract Function
	Extract Constant as Function Parameter
	Convert Symbol to CamelCase
	Complete Switch Statement
	Reformat Pointers or References
	Move Implementation to/from Source/Header
	Optimize For Loop

Eclipse CDT: free tool by eclipse.org
	<http://www.eclipse.org>
Refactorings:
	<http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Ftasks%2Fcdt_t_rename.htm>
	<https://wiki.eclipse.org/images/a/a1/C%2B%2B_Refactoring_-_Now_for_Real.pdf>
	Rename
	Extract Constant
	Extract Function
	Extract Local Variable
	Move Implementation to/from Source/Header
-- 
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
     The Computer Graphics Museum <http://ComputerGraphicsMuseum.org>
         The Terminals Wiki <http://terminals.classiccmp.org>
  Legalize Adulthood! (my blog) <http://LegalizeAdulthood.wordpress.com>



More information about the cfe-dev mailing list