mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-121180 Exception: Introduce parameter from final local var in anonymous class
This commit is contained in:
+3
-1
@@ -32,6 +32,7 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.VariableKind;
|
||||
import com.intellij.psi.search.LocalSearchScope;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.refactoring.JavaRefactoringSettings;
|
||||
import com.intellij.refactoring.RefactoringActionHandler;
|
||||
@@ -128,7 +129,8 @@ public class InplaceIntroduceParameterPopup extends AbstractJavaInplaceIntroduce
|
||||
|
||||
@Override
|
||||
protected PsiElement checkLocalScope() {
|
||||
return myMethod;
|
||||
final PsiVariable variable = getLocalVariable();
|
||||
return variable == null ? myMethod : PsiTreeUtil.getParentOfType(variable, PsiMethod.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
class Abc {
|
||||
void foo() {
|
||||
final String name = "name";
|
||||
|
||||
new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
foo();
|
||||
|
||||
}
|
||||
|
||||
private void foo() {
|
||||
System.out.println(na<caret>me);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
class Abc {
|
||||
void foo() {
|
||||
final String name = "name";
|
||||
|
||||
new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
foo(name);
|
||||
|
||||
}
|
||||
|
||||
private void foo(String name1) {
|
||||
System.out.println(name1);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +86,14 @@ public class InplaceIntroduceParameterTest extends AbstractJavaInplaceIntroduceT
|
||||
});
|
||||
}
|
||||
|
||||
public void testLocalInsideAnonymous() throws Exception {
|
||||
doTest(new Pass<AbstractInplaceIntroducer>() {
|
||||
@Override
|
||||
public void pass(AbstractInplaceIntroducer inplaceIntroducePopup) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return BASE_PATH;
|
||||
|
||||
Reference in New Issue
Block a user