JsonSchemaObject (@NotNull JsonValueAdapter value, List<JsonSchemaObject> oneOf) { final List<JsonSchemaAnnotatorChecker> candidateErroneousCheckers = new ArrayList<>(); final List<JsonSchemaObject> candidateErroneousSchemas = new ArrayList<>(); final List<JsonSchemaObject> correct = new SmartList<>(); for (JsonSchemaObject object : oneOf) { // skip it if something JS awaited, we do not process it currently if (object.isShouldValidateAgainstJSType()) continue; final JsonSchemaAnnotatorChecker checker = new JsonSchemaAnnotatorChecker(myProject, myOptions); checker.checkByScheme(value, object); if (checker.isCorrect()) { candidateErroneousCheckers.clear(); candidateErroneousSchemas.clear(); correct.add(object); } else { candidateErroneousCheckers.add(checker); candidateErroneousSchemas.add(object); } } if (correct.size() == 1) return correct.get(0); if (correct.size() > 0) { final JsonSchemaType type = JsonSchemaType.getType(value); if (type != null) { // also check maybe some currently not checked properties like format are different with schemes // todo note that JsonSchemaObject#equals is broken by design, so normally it shouldn't be used until rewritten // but for now we use it here to avoid similar schemas being marked as duplicates if (new HashSet<>(correct).size() > 1 && !schemesDifferWithNotCheckedProperties(correct)) { error(JsonBundle.message("schema.validation.to.more.than.one"), value.getDelegate(), JsonErrorPriority.MEDIUM_PRIORITY); } } return ContainerUtil.getLastItem(correct); } return showErrorsAndGetLeastErroneous(candidateErroneousCheckers, candidateErroneousSchemas, true); }