change signature: fix search for tags to remove in unsorted array (IDEA-147535)

This commit is contained in:
Anna Kozlova
2015-11-06 16:21:29 +01:00
parent 25d3334300
commit a6bd93a9c7
4 changed files with 68 additions and 2 deletions
@@ -41,6 +41,7 @@ import com.intellij.refactoring.util.*;
import com.intellij.refactoring.util.usageInfo.DefaultConstructorImplicitUsageInfo;
import com.intellij.refactoring.util.usageInfo.NoConstructorClassUsageInfo;
import com.intellij.usageView.UsageInfo;
import com.intellij.util.ArrayUtil;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.VisibilityUtil;
import com.intellij.util.containers.ContainerUtil;
@@ -857,13 +858,13 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
public boolean value(Pair<PsiParameter, String> pair) {
final PsiParameter parameter = pair.first;
final String oldParamName = pair.second;
final int idx = Arrays.binarySearch(oldParameterNames, oldParamName);
final int idx = ArrayUtil.find(oldParameterNames, oldParamName);
return idx >= 0 && idx == method.getParameterList().getParameterIndex(parameter) && changeInfo.getNewParameters()[idx].getOldIndex() == idx;
}
}, new Condition<String>() {
@Override
public boolean value(String paramName) {
return Arrays.binarySearch(oldParameterNames, paramName) >= 0;
return ArrayUtil.find(oldParameterNames, paramName) >= 0;
}
});
}
@@ -0,0 +1,30 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class C {
/**
* This is the role -
* @param role another desc
* @param labelExpression blah-blah
* @return return description
*/
public Integer ex<caret>ample(int role, String labelExpression) {
switch (role) {
case Constants.FOO:
break;
}
return 1;
}
}
@@ -0,0 +1,29 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class C {
/**
* This is the role -
* @param role another desc
* @return return description
*/
public Integer example(int role) {
switch (role) {
case Constants.FOO:
break;
}
return 1;
}
}
@@ -247,6 +247,12 @@ public class ChangeSignatureTest extends ChangeSignatureBaseTest {
}, false);
}
public void testJavadocOfDeleted() {
doTest(null, new ParameterInfoImpl[]{
new ParameterInfoImpl(0, "role", PsiType.INT),
}, false);
}
public void testCovariantReturnType() {
doTest(CommonClassNames.JAVA_LANG_RUNNABLE, new ParameterInfoImpl[0], false);
}