Community
Participate
Working Groups
There seems to be a code resolve change: it returns the type if a local var is selected. This breaks refactoring: before I could select a local var and then rename it but now I get a "Rename Type" wizard. It is no longer possible to rename a local variable.
The fundamental behavior shouldn't have changed. Selecting a local variable has always answered its actual declared type, given there is no such thing as an element for a local variable. Now it also does so for the variable declaration itself (where in the past it used to be doing nothing or misbehave in trying to lookup a type named like the variable). Can you provide a concrete test case ?
It does not happend for all local variables (but if it happens it does so in both cases i.e. on the declaration and where used). Test Case: - ensure to have the newest code of org.eclipse.search.internal.ui.CopyToClipboardAction.java from ZRH repository (I changed it today and that's where I saw the problem) NOTE: I have attached the corresponding CU - select "labelProvider" in run() - Refactor -> Rename Looking at Search which in all cases uses/gets the type it rather loooks like a JDT UI refactoring bug. BUT I think it is wrong to return the type if I do code resolve on a local variable name. It might be handy for F3/F4 but definitely isn't for search. IMO code resolve should not be smart (or should have two modes like strict and smart). It is not clear/logic to me that F3 on a field goes to the field while F3 on a local var is smart and goes to the declaring type (though this is rather UI related than a code resovle problem).
Created attachment 534 [details] CopyToClipboardAction.java
Selecting a local variable has always answered its type (except for declaration which answered nothing). How did it work before to rename local variable ?
weird - it must've returned null before because what my rename action does is: try resolving - if succesful then rename the resolved symbol if not succesful (null returned) - try, maybe it's a local variable
i will experiment with the opposite approach - i.e. try local vars first, use code resolve as a fallback and will let you know
it worked ok to close this report, i think
closed.