inline method: allow lambda inlining (IDEA-177994)

This commit is contained in:
Anna Kozlova
2017-08-24 18:16:56 +03:00
parent 3cab0cf983
commit d4b2a8c077
4 changed files with 23 additions and 1 deletions
@@ -1086,7 +1086,7 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
initializer.accept(canAllLocalsBeDeclaredFinal);
if (!canAllLocalsBeDeclaredFinal.success) return false;
}
if (initializer instanceof PsiMethodReferenceExpression) return true;
if (initializer instanceof PsiFunctionalExpression) return accessCount <= 1;
if (initializer instanceof PsiReferenceExpression) {
PsiVariable refVar = (PsiVariable)((PsiReferenceExpression)initializer).resolve();
if (refVar == null) {
@@ -0,0 +1,9 @@
class Foo {
void m(Runnable r) {}
void ff(Runnable r) {
m(r);
}
{
f<caret>f(() -> {});
}
}
@@ -0,0 +1,9 @@
class Foo {
void m(Runnable r) {}
void ff(Runnable r) {
m(r);
}
{
m(() -> {});
}
}
@@ -275,6 +275,10 @@ public class InlineMethodTest extends LightRefactoringTestCase {
doTestInlineThisOnly();
}
public void testOnLambda() {
doTestInlineThisOnly();
}
public void testNonCodeUsage() {
doTest(true);
}