Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] ASTRewrite rewrite



On Thu, Aug 4, 2011 at 4:37 AM, Lukas Felber <lfelber@xxxxxx> wrote:

>
> Please file a bug for the issue with Rename.

Done. https://bugs.eclipse.org/bugs/show_bug.cgi?id=353866

> Please notice that Rename uses somewhat different code that
> CRefactoring2-based refactorings.

I was aware of that. Since rename is the only refactoring which does not
request saving of resources before running, I created the example with
rename.

> Do you have an example of a similar issue for CRefactoring2-based
> refactorings?

Given the reason that all other refactorings than rename (I am on branch
master) request saving before running, I can only give examples by also
disabling this request for saving. This can be achieved by adding
"setSaveRequired(false);" to the constructor of RefactoringActions.

I applied your patch form
https://bugs.eclipse.org/bugs/show_bug.cgi?id=347712 to master for the
following example. Then I added a "setSaveRequired(false);" to
ExtractLocalVariableAction (which extends CRefactoring2) and created a
project containing the following files:

//file A.h
#include "j_def.h"
class A {
 void bar() {
   double i = j;
 }
};

//file j_def.h
int j = 0;

now change "int" int file j_def.h to "double" (do not save). Open file
A.h, select _expression_ "j" and call extract local variable. The
refactoring will work but produce a wrongly typed variable "int j0 =
j;". The type of "j0" should be "double" and not "int". The problem here
again is the indexer is not jet up to date and thus does not jet know
that the type of "j" in j_def.h has changed to "double", meaning that
when determining the type of the _expression_ "j" in A.h it yields "int"
instead of "double".

I can also provide you with malfunctioning examples of
ImplementMethodRefactoring and GenerateGettersAndSettersRefactoring
(which are the only remaining subclasses of CRefactoring2) if you like.

I did no file a bug for the problem described above since the problem is
not yet there (as long as the "setSaveRequired(false);" in the
refactorings' constructors are missing).

Thanks for the example. I'll look into it. 

Lukas

-sergey 

_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev


Back to the top