public static boolean isLocallyDefinedExpression(PsiExpression expression) {
    return PsiTreeUtil.processElements(expression, e -> {
      if (e instanceof PsiCallExpression) return false;
      if (e instanceof PsiReferenceExpression ref && ref.resolve() instanceof PsiField field) {
        return field.hasModifierProperty(PsiModifier.FINAL);
      }
      return !(e instanceof PsiArrayAccessExpression);
    });
  }
public static boolean isLocallyDefinedExpression(PsiExpression expression)