PsiLocalVariable (@NotNull PsiTypeCastExpression occurrence) { final PsiElement parent = PsiUtil.skipParenthesizedExprUp(occurrence.getParent()); if (parent instanceof PsiLocalVariable localVariable) { return localVariable; } if (parent instanceof PsiAssignmentExpression assignmentExpression && assignmentExpression.getLExpression() instanceof PsiReferenceExpression referenceExpression && referenceExpression.resolve() instanceof PsiLocalVariable localVariable) { return localVariable; } return null; }