void (final @NotNull PsiElement value, @Nullable JsonSchemaType currentType, final JsonSchemaType @NotNull ... allowedTypes) { if (allowedTypes.length == 0) return; String currentTypeDesc = currentType == null ? "" : (" " + JsonBundle.message("schema.validation.actual") + currentType.getName() + "."); String prefix = JsonBundle.message("schema.validation.incompatible.types") + "\n"; if (allowedTypes.length == 1) { error(prefix + " " + JsonBundle.message("schema.validation.required.one", allowedTypes[0].getName(), currentTypeDesc), value, JsonValidationError.FixableIssueKind.ProhibitedType, new JsonValidationError.TypeMismatchIssueData(allowedTypes), JsonErrorPriority.TYPE_MISMATCH); } else { final String typesText = Arrays.stream(allowedTypes) .map(JsonSchemaType::getName) .distinct() .sorted(Comparator.naturalOrder()) .collect(Collectors.joining(", ")); error(prefix + " " + JsonBundle.message("schema.validation.required.one.of", typesText, currentTypeDesc), value, JsonValidationError.FixableIssueKind.ProhibitedType, new JsonValidationError.TypeMismatchIssueData(allowedTypes), JsonErrorPriority.TYPE_MISMATCH); } myHadTypeError = true; }