introduce variable from lambda expression

This commit is contained in:
anna
2012-07-24 17:51:51 +02:00
parent 1ee26f5d5c
commit e0cad5f568
8 changed files with 60 additions and 7 deletions
@@ -0,0 +1,11 @@
interface SAM<X> {
X m(int i, int j);
}
class Foo {
void test() {
SAM<Integer> c = (i, j)->i + j;
m(c);
}
void m(SAM<Integer> s) { }
}
@@ -0,0 +1,10 @@
interface SAM<X> {
X m(int i, int j);
}
class Foo {
void test() {
m(<selection>(i, j) -> i + j</selection>);
}
void m(SAM<Integer> s) { }
}
@@ -0,0 +1,11 @@
interface SAM<X> {
X m(int i, int j);
}
class Foo {
void test() {
SAM<Integer> c = (i, j)->"" + i + j;
SAM<Integer> s3 = m(c);
}
<X> SAM<X> m(SAM<X> s) { return null; }
}
@@ -0,0 +1,10 @@
interface SAM<X> {
X m(int i, int j);
}
class Foo {
void test() {
SAM<Integer> s3 = m(<selection>(i, j) -> "" + i + j</selection>);
}
<X> SAM<X> m(SAM<X> s) { return null; }
}
@@ -335,6 +335,14 @@ public class IntroduceVariableTest extends LightCodeInsightTestCase {
doTest(new MockIntroduceVariableHandler("c", false, false, false, CommonClassNames.JAVA_LANG_OBJECT));
}
public void testLambdaExpr() throws Exception {
doTest(new MockIntroduceVariableHandler("c", false, false, false, "SAM<java.lang.Integer>"));
}
public void testLambdaExprNotAccepted() throws Exception {
doTest(new MockIntroduceVariableHandler("c", false, false, false, "SAM<java.lang.Integer>"));
}
private void doTest(IntroduceVariableBase testMe) throws Exception {
@NonNls String baseName = "/refactoring/introduceVariable/" + getTestName(false);
configureByFile(baseName + ".java");