mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inline method: allow lambda inlining (IDEA-177994)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user