boolean (PsiExpressionStatement expressionStatement, PsiField field) { final PsiExpression expression = expressionStatement.getExpression(); if (!(expression instanceof PsiAssignmentExpression assignmentExpression)) { return false; } final PsiExpression lhs = PsiUtil.skipParenthesizedExprDown(assignmentExpression.getLExpression()); if (!(lhs instanceof PsiReferenceExpression referenceExpression)) { return false; } if (!field.equals(referenceExpression.resolve())) { return false; } final PsiExpression rhs = assignmentExpression.getRExpression(); final boolean safe = PsiTreeUtil.processElements(rhs, PsiReferenceExpression.class, ref -> { final PsiElement target = ref.resolve(); return !(target instanceof PsiLocalVariable) && !(target instanceof PsiParameter); }); if (!safe) { return false; } final PsiElement[] elements = rhs == null ? PsiElement.EMPTY_ARRAY : new PsiElement[] {rhs}; final HashSet<PsiField> usedFields = new HashSet<>(); final PsiClass targetClass = field.getContainingClass(); return CommonJavaRefactoringUtil.canBeStatic(targetClass, expressionStatement, elements, usedFields) && usedFields.isEmpty(); }