boolean (@Nullable PsiExpression expression, @NotNull PsiVariable variable, int stamp, @NotNull Set<MethodSignature> checkedMethods) { if (counter != stamp) { return true; } if (expression == null) { return false; } if (expression instanceof PsiThisExpression || expression instanceof PsiLiteralExpression || expression instanceof PsiSuperExpression || expression instanceof PsiClassObjectAccessExpression || expression instanceof PsiLambdaExpression) { return false; } else if (expression instanceof PsiReferenceExpression referenceExpression) { return referenceExpressionAssignsVariable(referenceExpression, variable, stamp, checkedMethods); } else if (expression instanceof PsiMethodCallExpression callExpression) { return methodCallAssignsVariable(callExpression, variable, stamp, checkedMethods); } else if (expression instanceof PsiNewExpression newExpression) { return newExpressionAssignsVariable(newExpression, variable, stamp, checkedMethods); } else if (expression instanceof PsiArrayInitializerExpression array) { final PsiExpression[] initializers = array.getInitializers(); for (final PsiExpression initializer : initializers) { if (expressionAssignsVariable(initializer, variable, stamp, checkedMethods)) { return true; } } return false; } else if (expression instanceof PsiTypeCastExpression typeCast) { final PsiExpression operand = typeCast.getOperand(); return expressionAssignsVariable(operand, variable, stamp, checkedMethods); } else if (expression instanceof PsiArrayAccessExpression accessExpression) { final PsiExpression arrayExpression = accessExpression.getArrayExpression(); final PsiExpression indexExpression = accessExpression.getIndexExpression(); return expressionAssignsVariable(arrayExpression, variable, stamp, checkedMethods) || expressionAssignsVariable(indexExpression, variable, stamp, checkedMethods); } else if (expression instanceof PsiUnaryExpression unaryExpression) { final PsiExpression operand = unaryExpression.getOperand(); return expressionAssignsVariable(operand, variable, stamp, checkedMethods); } else if (expression instanceof PsiPolyadicExpression polyadicExpression) { final PsiExpression[] operands = polyadicExpression.getOperands(); for (PsiExpression operand : operands) { if (expressionAssignsVariable(operand, variable, stamp, checkedMethods)) { return true; } } return false; } else if (expression instanceof PsiConditionalExpression conditional) { final PsiExpression condition = conditional.getCondition(); if (expressionAssignsVariable(condition, variable, stamp, checkedMethods)) { return true; } final PsiExpression thenExpression = conditional.getThenExpression(); final PsiExpression elseExpression = conditional.getElseExpression(); return expressionAssignsVariable(thenExpression, variable, stamp, checkedMethods) && expressionAssignsVariable(elseExpression, variable, stamp, checkedMethods); } else if (expression instanceof PsiAssignmentExpression assignment) { return assignmentExpressionAssignsVariable(assignment, variable, stamp, checkedMethods); } else if (expression instanceof PsiParenthesizedExpression parenthesizedExpression) { final PsiExpression innerExpression = parenthesizedExpression.getExpression(); return expressionAssignsVariable(innerExpression, variable, stamp, checkedMethods); } else if (expression instanceof PsiInstanceOfExpression instanceOfExpression) { final PsiExpression operand = instanceOfExpression.getOperand(); return expressionAssignsVariable(operand, variable, stamp, checkedMethods); } else if (expression instanceof PsiSwitchExpression switchExpression) { return switchBlockAssignsVariable(switchExpression, variable, stamp, checkedMethods); } else { return false; } }