Well, I spent most of this week adding tests and fixing bug in rfta. The
first unit test for the RenameTemp refactoring is finally passing.
The code lives in src/rfta and include/rfta/refactoring. It's a dll that
depends on the rftaparser dll. The UT demonstrating the refactoring is in
RenameTempRefactoringTest.
This is the 'basic' implementation: it does not handle temporary with
the same name declared in subscope, but does most of the steps described on
the CppRefactorings wiki page:
1. Find occurrences of the temporary's identifier in the temporary scope
At the current time, search all the occurences in the parent compound
statement of the temporary.
2. Increase the parsing level of detail of the statement that contains the
identifier until it's known wether it reference the temporary or not (Notes:
may be instead of yes/no, we should extract the likelihood it is a reference
to the temporary).
Expands everything at the current time, though the VariableDeclVisitor could
probably be expanded to handle that. Also, only the node that can possibly
declares a variable are visited (thanks to the node type 'features').
It seems that the search for reference to the temporary is fail-proof, so no
need for fuzzy stuff at the momemnt.
3. Asks for user approval
Not really needed, since no possible can occurs.
4. Replace occurences of the identifier with the new identifier
We just do that...
The most important part of the magic other than the VariableDeclMutator
lives in ToolsBox::IsNotVariablePred.
Well, I think I'll try to make a VC6 add-in to use it. This will
probably helps find bugs... Then, scope handling can be dealt with.
Baptiste.
|