safe delete: fix initialization order

This commit is contained in:
Anna Kozlova
2014-11-27 18:12:49 +01:00
parent 0494c00df6
commit 6ff126e422
2 changed files with 11 additions and 7 deletions
@@ -279,7 +279,12 @@ public class JavaSafeDeleteProcessor extends SafeDeleteProcessorDelegateBase {
final PsiMethod method = parameterHierarchyUsageInfo.getCalledMethod();
final PsiParameter parameter = parameterHierarchyUsageInfo.getReferencedElement();
final int parameterIndex = method.getParameterList().getParameterIndex(parameter);
final JavaCallerChooser chooser = new SafeDeleteJavaCallerChooser(method, project, parameterIndex, result);
final JavaCallerChooser chooser = new SafeDeleteJavaCallerChooser(method, project, result) {
@Override
protected int getParameterIdx() {
return parameterIndex;
}
};
if (!chooser.showAndGet()) {
return null;
}
@@ -23,7 +23,6 @@ import com.intellij.openapi.util.Ref;
import com.intellij.psi.*;
import com.intellij.psi.search.LocalSearchScope;
import com.intellij.psi.search.searches.ReferencesSearch;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.refactoring.changeSignature.MethodNodeBase;
import com.intellij.refactoring.changeSignature.inCallers.JavaCallerChooser;
@@ -38,17 +37,15 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
class SafeDeleteJavaCallerChooser extends JavaCallerChooser {
abstract class SafeDeleteJavaCallerChooser extends JavaCallerChooser {
private final PsiMethod myMethod;
private final Project myProject;
private final int myParameterIndex;
private final ArrayList<UsageInfo> myResult;
public SafeDeleteJavaCallerChooser(PsiMethod method, Project project, int parameterIndex, ArrayList<UsageInfo> result) {
public SafeDeleteJavaCallerChooser(PsiMethod method, Project project, ArrayList<UsageInfo> result) {
super(method, project, "Select Methods To Propagate Parameter Deletion", null, Consumer.EMPTY_CONSUMER);
myMethod = method;
myProject = project;
myParameterIndex = parameterIndex;
myResult = result;
}
@@ -56,9 +53,11 @@ class SafeDeleteJavaCallerChooser extends JavaCallerChooser {
protected JavaMethodNode createTreeNode(PsiMethod nodeMethod,
com.intellij.util.containers.HashSet<PsiMethod> called,
Runnable cancelCallback) {
return new SafeDeleteJavaMethodNode(nodeMethod, called, cancelCallback, myParameterIndex, nodeMethod != null ? nodeMethod.getProject() : myProject);
return new SafeDeleteJavaMethodNode(nodeMethod, called, cancelCallback, getParameterIdx(), nodeMethod != null ? nodeMethod.getProject() : myProject);
}
protected abstract int getParameterIdx();
@Override
protected void doOKAction() {
final List<UsageInfo> foreignMethodUsages = new ArrayList<UsageInfo>();