introduce variable: distinguish lambda parameters but allow param free expressions (IDEA-163785)

This commit is contained in:
Anna.Kozlova
2016-11-10 17:47:28 +01:00
parent 8c4e0bb450
commit fd89b0ed18
4 changed files with 54 additions and 17 deletions
@@ -0,0 +1,15 @@
import java.util.function.UnaryOperator;
class Main {
public static void main(String[] args) {
UnaryOperator<String> f1 = s -> {
System.out.println("foo");
String temp = s.trim();
return temp;
};
UnaryOperator<String> f2 = s -> {
System.out.println("foo");
return s.trim();
};
}
}
@@ -0,0 +1,14 @@
import java.util.function.UnaryOperator;
class Main {
public static void main(String[] args) {
UnaryOperator<String> f1 = s -> {
System.out.println("foo");
return <selection>s.trim()</selection>;
};
UnaryOperator<String> f2 = s -> {
System.out.println("foo");
return s.trim();
};
}
}
@@ -211,6 +211,10 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
doTest(new MockIntroduceVariableHandler("temp", true, false, false, "int"));
}
public void testDistinguishLambdaParams() {
doTest(new MockIntroduceVariableHandler("temp", true, false, false, CommonClassNames.JAVA_LANG_STRING));
}
public void testDuplicateGenericExpressions() {
doTest(new MockIntroduceVariableHandler("temp", true, false, false, "Foo2<? extends java.lang.Runnable>"));
}