mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
inplace introduce: try our best to restore complex expressions during introduce (IDEA-80665)
This commit is contained in:
+10
-2
@@ -132,8 +132,16 @@ public abstract class AbstractJavaInplaceIntroducer extends AbstractInplaceIntro
|
||||
if (expression == null) {
|
||||
expression = PsiTreeUtil.getParentOfType(refVariableElement, PsiExpression.class);
|
||||
}
|
||||
if (expression instanceof PsiReferenceExpression && expression.getParent() instanceof PsiMethodCallExpression) {
|
||||
expression = (PsiExpression)expression.getParent();
|
||||
while (expression instanceof PsiReferenceExpression) {
|
||||
final PsiElement parent = expression.getParent();
|
||||
if (parent instanceof PsiMethodCallExpression) {
|
||||
if (parent.getText().equals(exprText)) return (PsiExpression)parent;
|
||||
}
|
||||
if (parent instanceof PsiExpression) {
|
||||
expression = (PsiExpression)parent;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return expression != null && expression.isValid() && expression.getText().equals(exprText) ? expression : null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user