mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inplace introduce parameter: ensure that parameter is not deleted if not all occurrences are replaced
This commit is contained in:
+5
-3
@@ -97,9 +97,11 @@ public class InplaceIntroduceParameterPopup extends AbstractJavaInplaceIntroduce
|
||||
|
||||
protected TIntArrayList getParametersToRemove() {
|
||||
TIntArrayList parameters = new TIntArrayList();
|
||||
for (int i = 0; i < myParametersToRemove.length; i++) {
|
||||
if (myParametersToRemove[i] != null) {
|
||||
parameters.add(i);
|
||||
if (myCbReplaceAllOccurences == null || myCbReplaceAllOccurences.isSelected()) {
|
||||
for (int i = 0; i < myParametersToRemove.length; i++) {
|
||||
if (myParametersToRemove[i] != null) {
|
||||
parameters.add(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return parameters;
|
||||
|
||||
+3
@@ -243,6 +243,9 @@ public abstract class IntroduceParameterSettingsUI {
|
||||
}
|
||||
|
||||
public boolean isParamToRemove(PsiParameter param) {
|
||||
if (myCbReplaceAllOccurences != null && !myCbReplaceAllOccurences.isSelected()) {
|
||||
return false;
|
||||
}
|
||||
if (param.isVarArgs()) {
|
||||
return myParametersToRemove[myParametersToRemove.length - 1] != null;
|
||||
}
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class Test {
|
||||
void foo(int i) {
|
||||
System.out.println(<caret>i);
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class Test {
|
||||
void foo(int i, int i1) {
|
||||
System.out.println(i1);
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
@@ -60,6 +60,14 @@ public class InplaceIntroduceParameterTest extends AbstractJavaInplaceIntroduceT
|
||||
});
|
||||
}
|
||||
|
||||
public void testReplaceOneLeaveParamToDelete() throws Exception {
|
||||
doTest(new Pass<AbstractInplaceIntroducer>() {
|
||||
@Override
|
||||
public void pass(AbstractInplaceIntroducer inplaceIntroduceFieldPopup) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testReplaceAllBrokenIdentifier() throws Exception {
|
||||
doTest(new Pass<AbstractInplaceIntroducer>() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user