introduce functional parameter: exclude only selection range from used parameters check as for functional interfaces the whole code block is treated as selection's parent (IDEA-154299)

This commit is contained in:
Anna.Kozlova
2016-09-27 09:22:01 +02:00
parent 31927c0d07
commit 9863deb8d9
6 changed files with 82 additions and 0 deletions
@@ -0,0 +1,38 @@
import java.util.function.BooleanSupplier;
class A2 {
void method(MyObject obj, BooleanSupplier anObject) {
obj.method1();
if (anObject.getAsBoolean()) {
doOtherStaff();
}
obj.method2();
}
{
final MyObject obj = new MyObject();
method(obj, new BooleanSupplier() {
public boolean getAsBoolean() {
return obj.isCondition1();
}
});
}
private void doOtherStaff() {
}
private class MyObject {
public void method1() {
}
public boolean isCondition1() {
return true;
}
public void method2() {
}
}
}
@@ -0,0 +1,32 @@
class A2 {
void method(MyObject obj) {
obj.method1();
if (<selection>obj.isCondition1()</selection>) {
doOtherStaff();
}
obj.method2();
}
{
method(new MyObject());
}
private void doOtherStaff() {
}
private class MyObject {
public void method1() {
}
public boolean isCondition1() {
return true;
}
public void method2() {
}
}
}
@@ -70,6 +70,10 @@ public class IntroduceFunctionalParameterTest extends LightRefactoringTestCase
doTest();
}
public void testUsedParametersOutsideSelectedFragment() throws Exception {
doTest();
}
@NotNull
@Override
protected String getTestDataPath() {