inline local: fix for outer lambda + nested lambda/class (IDEA-174979)

This commit is contained in:
Anna Kozlova
2017-06-26 16:11:56 +03:00
parent 70170d6f19
commit 3766febf2e
4 changed files with 20 additions and 1 deletions
@@ -84,7 +84,7 @@ public class InlineLocalHandler extends JavaInlineActionHandler {
final List<PsiElement> innerClassesWithUsages = Collections.synchronizedList(new ArrayList<PsiElement>());
final List<PsiElement> innerClassUsages = Collections.synchronizedList(new ArrayList<PsiElement>());
final PsiClass containingClass = PsiTreeUtil.getParentOfType(local, PsiClass.class);
final PsiElement containingClass = PsiTreeUtil.getParentOfType(local, PsiClass.class, PsiLambdaExpression.class);
final Query<PsiReference> query = ReferencesSearch.search(local);
if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
if (query.findFirst() == null){
@@ -0,0 +1,8 @@
class Foo {
void foo(String s) {
Runnable r = () -> {
String s2 = s.toString();
Runnable r2 = () -> System.out.println(s<caret>2);
};
}
}
@@ -0,0 +1,7 @@
class Foo {
void foo(String s) {
Runnable r = () -> {
Runnable r2 = () -> System.out.println(s.toString());
};
}
}
@@ -301,6 +301,10 @@ public class InlineLocalTest extends LightCodeInsightTestCase {
doTest(false);
}
public void testLocalInsideLambdaWithNestedLambda() throws Exception {
doTest(true);
}
private void doTest(final boolean inlineDef, String conflictMessage) throws Exception {
try {
doTest(inlineDef);