PsiVariable (PsiMethodCallExpression expression) { final PsiElement parent = PsiTreeUtil.skipParentsOfType(expression, PsiParenthesizedExpression.class); if (parent instanceof PsiVariable) { return (PsiVariable)parent; } if (!(parent instanceof PsiAssignmentExpression assignmentExpression)) { return null; } final PsiExpression rhs = assignmentExpression.getRExpression(); if (!PsiTreeUtil.isAncestor(rhs, expression, false)) { return null; } final PsiExpression lhs = PsiUtil.skipParenthesizedExprDown(assignmentExpression.getLExpression()); if (!(lhs instanceof PsiReferenceExpression referenceExpression)) { return null; } final PsiElement target = referenceExpression.resolve(); if (!(target instanceof PsiVariable)) { return null; } return (PsiVariable)target; }