@Nullable
  public static PsiExpression getInitializer(PsiField field) {
    if (field.hasInitializer()) {
      PsiExpression initializer = field.getInitializer();
      if (initializer instanceof PsiCompiledElement) {
        // Could be a literal initializer: we still can inline it, though passing compiled element downstream may cause exceptions
        initializer = JavaPsiFacade.getElementFactory(field.getProject()).createExpressionFromText(initializer.getText(), field);
      }
      return initializer;
    }

    if (field.hasModifierProperty(PsiModifier.FINAL)) {
      PsiClass containingClass = field.getContainingClass();
      if (containingClass != null) {
        PsiMethod[] constructors = containingClass.getConstructors();
        final List<PsiExpression> result = new ArrayList<>();
        for (PsiReference reference : ReferencesSearch.search(field, new LocalSearchScope(constructors))) {
          final PsiElement element = reference.getElement();
          if (element instanceof PsiReferenceExpression && PsiUtil.isOnAssignmentLeftHand((PsiExpression)element)) {
            PsiAssignmentExpression assignmentExpression = PsiTreeUtil.getParentOfType(element, PsiAssignmentExpression.class);
            if (assignmentExpression != null) {
              ContainerUtil.addIfNotNull(result, assignmentExpression.getRExpression());
            }
          }
        }

        if (result.isEmpty()) return null;

        PsiExpression first = result.get(0);
        for (PsiExpression expr : result) {
          if (!PsiEquivalenceUtil.areElementsEquivalent(expr, first)) {
            return null;
          }
        }
        return first;
      }
    }

    return null;
  }
@Nullable
  public static PsiExpression getInitializer(PsiField field)