perform real rename on automatically suggested vars (comment for IDEA-94844)

This commit is contained in:
anna
2012-11-15 14:19:38 +01:00
parent 1a1f28fbec
commit f404977664
5 changed files with 34 additions and 1 deletions
@@ -0,0 +1,10 @@
interface F {
void foo(int <caret>i);
}
class A implements F {
int myI;
public void foo(int i){
myI = i;
}
}
@@ -0,0 +1,10 @@
interface F {
void foo(int myI);
}
class A implements F {
int myI;
public void foo(int myI){
this.myI = myI;
}
}
@@ -77,6 +77,10 @@ public class RenameLocalTest extends LightRefactoringTestCase {
doTestInplaceRename("myI");
}
public void testRenameInPlaceQualifyFieldReferenceInChild() throws Exception {
doTestInplaceRename("myI");
}
public void testRenameInPlaceThisNeeded() throws Exception {
doTestInplaceRename("a");
}
@@ -24,6 +24,14 @@ import org.jetbrains.annotations.NotNull;
* @author dsl
*/
public interface RefactoringElementListener {
RefactoringElementListener DEAF = new RefactoringElementListener() {
@Override
public void elementMoved(@NotNull PsiElement newElement) {}
@Override
public void elementRenamed(@NotNull PsiElement newElement) {}
};
/**
* Invoked in write action and command.
*/
@@ -36,6 +36,7 @@ import com.intellij.psi.*;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.refactoring.RefactoringBundle;
import com.intellij.refactoring.listeners.RefactoringElementListener;
import com.intellij.refactoring.rename.AutomaticRenamingDialog;
import com.intellij.refactoring.rename.RenameHandlerRegistry;
import com.intellij.refactoring.rename.RenameProcessor;
@@ -240,7 +241,7 @@ public class VariableInplaceRenamer extends InplaceRefactoring {
final String newElementName = renamer.getNewName(element);
if (newElementName != null) {
final Collection<UsageInfo> infos = classified.get(element);
RenameUtil.doRenameGenericNamedElement(element, newElementName, infos.toArray(new UsageInfo[infos.size()]), null);
RenameUtil.doRename(element, newElementName, infos.toArray(new UsageInfo[infos.size()]), myProject, RefactoringElementListener.DEAF);
}
}
}