introduce variable from one line lambda transforms body to code block (IDEA-91122)

This commit is contained in:
Anna Kozlova
2012-09-06 19:10:15 +04:00
parent 3ee8a858bd
commit a8ea5d4deb
7 changed files with 66 additions and 2 deletions
@@ -0,0 +1,8 @@
class Foo {
void test() {
Comparable<String> java = o -> {
int c = o.length();
return c;
};
}
}
@@ -0,0 +1,5 @@
class Foo {
void test() {
Comparable<String> java = o -> <selection>o.length()</selection>;
}
}
@@ -0,0 +1,8 @@
class Foo {
void test() {
Runnable java = () -> {
String c = "";
System.out.println(c);
};
}
}
@@ -0,0 +1,5 @@
class Foo {
void test() {
Runnable java = () -> System.out.println(<selection>""</selection>);
}
}
@@ -371,6 +371,13 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
doTest(new MockIntroduceVariableHandler("c", false, false, false, "SAM<java.lang.String>"));
}
public void testOneLineLambdaVoidCompatible() throws Exception {
doTest(new MockIntroduceVariableHandler("c", false, false, false, "java.lang.String"));
}
public void testOneLineLambdaValueCompatible() throws Exception {
doTest(new MockIntroduceVariableHandler("c", false, false, false, "int"));
}
private void doTest(IntroduceVariableBase testMe) throws Exception {
@NonNls String baseName = "/refactoring/introduceVariable/" + getTestName(false);
configureByFile(baseName + ".java");