@Override
  public final void visitNewExpression(@NotNull PsiNewExpression expression) {
    super.visitNewExpression(expression);
    final PsiType type = expression.getType();
    if (!(type instanceof PsiClassType classType)) {
      return;
    }
    final PsiType expectedType = ExpectedTypeUtils.findExpectedType(expression, false);
    if (!(expectedType instanceof PsiClassType)) {
      return;
    }
    if (!classType.hasParameters()) {
      classType = (PsiClassType)expectedType;
    }
    final PsiType[] typeArguments = classType.getParameters();
    if (typeArguments.length == 0) {
      return;
    }
    final PsiType argumentType = typeArguments[0];
    if (!(argumentType instanceof PsiClassType argumentClassType)) {
      return;
    }
    if (!TypeUtils.expressionHasTypeOrSubtype(expression, getBaseCollectionName())) {
      return;
    }
    if (TypeUtils.expressionHasTypeOrSubtype(expression, getReplacementCollectionName()) ||
        TypeUtils.expressionHasTypeOrSubtype(expression, getUnreplaceableCollectionNames())) {
      return;
    }
    final PsiClass argumentClass = argumentClassType.resolve();
    if (argumentClass == null || !argumentClass.isEnum()) {
      return;
    }
    final PsiClass aClass = PsiTreeUtil.getParentOfType(expression, PsiClass.class);
    if (argumentClass.equals(aClass)) {
      final PsiMember member = PsiTreeUtil.getParentOfType(expression, PsiMember.class);
      if (member != null && !member.hasModifierProperty(PsiModifier.STATIC)) {
        return;
      }
    }
    final PsiExpressionList argumentList = expression.getArgumentList();
    if (argumentList != null) {
      final PsiExpression[] arguments = argumentList.getExpressions();
      if (arguments.length > 0 && TypeUtils.expressionHasTypeOrSubtype(arguments[0], "java.util.Comparator")) {
        return;
      }
    }
    PsiClassType replacementCollectionType = TypeUtils.getType(getReplacementCollectionName(), expression);
    if (!expectedType.isAssignableFrom(replacementCollectionType) && !isReplaceableType((PsiClassType)expectedType)) {
      return;
    }
    PsiElement parent = PsiUtil.skipParenthesizedExprUp(expression.getParent());
    PsiLocalVariable localVariable = tryCast(parent, PsiLocalVariable.class);
    if (localVariable != null) {
      PsiClass localVariableClass = PsiUtil.resolveClassInClassTypeOnly(localVariable.getType());
      if (localVariableClass != null && getBaseCollectionName().equals(localVariableClass.getQualifiedName())) {
        registerNewExpressionError(expression, localVariable);
      }
      else {
        registerNewExpressionError(expression);
      }
    }
    else {
      registerNewExpressionError(expression);
    }
  }
@Override
  public final void visitNewExpression(@NotNull PsiNewExpression expression)