introduce parameter: replace field access with getter: correct anonymous class access; check qualifier

This commit is contained in:
anna
2011-08-21 14:46:36 +02:00
parent 2a1f09810f
commit 1ed82c5609
4 changed files with 59 additions and 6 deletions
@@ -0,0 +1,23 @@
public class Test {
private String myStr;
public String getMyStr() {
return myStr;
}
void foo(String anObject) {
new Runnable(){
@Override
public void run() {
System.out.println(anObject);
}
};
}
}
class X {
public void n() {
final Test test = new Test();
test.foo(test.getMyStr());
}
}
@@ -0,0 +1,22 @@
public class Test {
private String myStr;
public String getMyStr() {
return myStr;
}
void foo() {
new Runnable(){
@Override
public void run() {
System.out.println(<selection>myStr</selection>);
}
};
}
}
class X {
public void n() {
new Test().foo();
}
}
@@ -244,6 +244,10 @@ public class IntroduceParameterTest extends LightCodeInsightTestCase {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false, false);
}
public void testGetterQualifier() throws Exception {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, false, false, false, false);
}
public void testIncompleteEnumDefinition() throws Exception {
doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, true, false, false, false, "Incomplete call(Root()): 2 parameters expected but only 0 found\n" +
"Incomplete call(Root()): expected to delete the 1 parameter but only 0 parameters found");