diff --git a/json/src/com/jetbrains/jsonSchema/impl/JsonSchemaObject.java b/json/src/com/jetbrains/jsonSchema/impl/JsonSchemaObject.java index 2feb02fe389d..643b2252651c 100644 --- a/json/src/com/jetbrains/jsonSchema/impl/JsonSchemaObject.java +++ b/json/src/com/jetbrains/jsonSchema/impl/JsonSchemaObject.java @@ -644,44 +644,32 @@ public class JsonSchemaObject { current = current.getProperties().get(parts.get(++i)); continue; } - Pair arrayResult = ObjectUtils.coalesce( - handleArrayItem(ITEMS, parts, i, current.getItemsSchema(), current.getItemsSchemaList()), - handleArrayItem(ADDITIONAL_ITEMS, parts, i, current.getAdditionalItemsSchema(), ContainerUtil.emptyList())); - if (arrayResult != null) { - //noinspection AssignmentToForLoopParameter - i = arrayResult.second; - current = arrayResult.first; + if (ITEMS.equals(part)) { + if (i == (parts.size() - 1)) { + current = current.getItemsSchema(); + } + else { + //noinspection AssignmentToForLoopParameter + Integer next = tryParseInt(parts.get(++i)); + List itemsSchemaList = current.getItemsSchemaList(); + if (itemsSchemaList != null && next != null && next < itemsSchemaList.size()) { + current = itemsSchemaList.get(next); + } + } continue; } + if (ADDITIONAL_ITEMS.equals(part)) { + if (i == (parts.size() - 1)) { + current = current.getAdditionalItemsSchema(); + } + continue; + } + current = current.getDefinitionsMap() == null ? null : current.getDefinitionsMap().get(part); } return current; } - @Nullable - private static Pair handleArrayItem(@NotNull String name, - List parts, - int i, - @Nullable JsonSchemaObject arraySchema, - @Nullable List arraySchemaList) { - final String part = parts.get(i); - if (!name.equals(part)) { - return null; - } - if (i == (parts.size() - 1)) { - if (arraySchema != null) { - return Pair.create(arraySchema, i); - } - } - else { - Integer next = tryParseInt(parts.get(++i)); - if (arraySchemaList != null && next != null && next >= 0 && next < arraySchemaList.size()) { - return Pair.create(arraySchemaList.get(next), i); - } - } - return null; - } - @Nullable private static Integer tryParseInt(String s) { try {