@Override
  public void onMarkReferenced(RefElement refWhat,
                               RefElement refFrom,
                               boolean referencedFromClassInitializer,
                               boolean forReading,
                               boolean forWriting,
                               PsiElement referenceElement) {
    if (!forWriting) return;
    if (!(refWhat instanceof RefField refField)) return;
    if (refFrom instanceof RefClass && refField.getOwnerClass() != refFrom) {
      ((RefFieldImpl)refWhat).setFlag(false, CAN_BE_FINAL_MASK);
    }
    else if (refField.getUastElement().getUastInitializer() != null) {
      ((RefFieldImpl)refWhat).setFlag(false, CAN_BE_FINAL_MASK);
    }
    else if (!(refFrom instanceof RefMethod) ||
             !((RefMethod)refFrom).isConstructor() ||
             ((RefMethod)refFrom).getOwnerClass() != refField.getOwnerClass() ||
             refField.isStatic()) {
      if (!referencedFromClassInitializer || PsiTreeUtil.getParentOfType(referenceElement, PsiLambdaExpression.class, true) != null) {
        ((RefFieldImpl)refWhat).setFlag(false, CAN_BE_FINAL_MASK);
      }
    }
    else if (PsiTreeUtil.getParentOfType(referenceElement, PsiLambdaExpression.class, true) != null) {
      ((RefFieldImpl)refWhat).setFlag(false, CAN_BE_FINAL_MASK);
    }
  }
@Override
  public void onMarkReferenced(RefElement refWhat,
                               RefElement refFrom,
                               boolean referencedFromClassInitializer,
                               boolean forReading,
                               boolean forWriting,
                               PsiElement referenceElement)