inline parameter: do not warn about inaccessible propagated parameter

This commit is contained in:
anna
2013-12-05 20:29:44 +01:00
parent 022615c0f8
commit daba93f3a6
4 changed files with 33 additions and 1 deletions
@@ -342,7 +342,15 @@ public class InlineParameterExpressionProcessor extends BaseRefactoringProcessor
myConflicts.putValue(expression, "Parameter initializer depends on value which is not available inside method");
}
} else if (element instanceof PsiParameter) {
myConflicts.putValue(expression, "Parameter initializer depends on callers parameter");
boolean bound = false;
for (PsiParameter parameter : myMethod.getParameterList().getParameters()) {
if (parameter.getType().equals(((PsiParameter)element).getType()) && parameter.getName().equals(((PsiParameter)element).getName())) {
bound = true;
}
}
if (!bound) {
myConflicts.putValue(expression, "Parameter initializer depends on callers parameter");
}
}
}
@@ -0,0 +1,10 @@
class X {
void bar(String str){
foo(str, str.substring(0));
}
void foo(String str, String st<caret>r1) {
System.out.println(str);
System.out.println(str1);
}
}
@@ -0,0 +1,10 @@
class X {
void bar(String str){
foo(str);
}
void foo(String str) {
System.out.println(str);
System.out.println(str.substring(0));
}
}
@@ -138,6 +138,10 @@ public class InlineParameterTest extends LightRefactoringTestCase {
doTest(false);
}
public void testPropagatedParams() throws Exception {
doTest(false);
}
public void testParameterWithWriteAccess() throws Exception {
try {
doTest(false);