Skip to main content

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

> 
> 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).

Lukas



Back to the top