[java] update all references in move into anonymous object fix IDEA-293156

GitOrigin-RevId: cbd3dc55d65f2b6736b1349ba60c6334945e35e5
This commit is contained in:
Roman Ivanov
2022-04-28 09:32:37 +00:00
committed by intellij-monorepo-bot
parent cf2739c5c2
commit 94b0e67907
3 changed files with 23 additions and 0 deletions
@@ -229,6 +229,7 @@ public class VariableAccessFromInnerClassJava10Fix extends BaseIntentionAction {
outerCodeBlock.accept(new JavaRecursiveElementVisitor() {
@Override
public void visitReferenceExpression(PsiReferenceExpression expression) {
super.visitReferenceExpression(expression);
if (ExpressionUtils.isReferenceTo(expression, variable)) {
references.add(expression);
}
@@ -0,0 +1,12 @@
// "Move 'condition' into anonymous object" "true"
class Test {
public void test() {
var ref = new Object() {
Object condition;
};
Runnable r = () -> {
ref.condition = new Object();
ref.condition.hashCode();
};
}
}
@@ -0,0 +1,10 @@
// "Move 'condition' into anonymous object" "true"
class Test {
public void test() {
Object condition;
Runnable r = () -> {
condition<caret> = new Object();
condition.hashCode();
};
}
}