void (@Nullable JsonSchemaAnnotatorChecker checker) { if (checker == null || checker.isCorrect()) return; // compute intersecting ranges - we'll solve warning priorities based on this information List<TextRange> ranges = new ArrayList<>(); List<List<Map.Entry<PsiElement, JsonValidationError>>> entries = new ArrayList<>(); for (Map.Entry<PsiElement, JsonValidationError> entry : checker.getErrors().entrySet()) { TextRange range = myWalker.adjustErrorHighlightingRange(entry.getKey()); boolean processed = false; for (int i = 0; i < ranges.size(); i++) { TextRange currRange = ranges.get(i); if (currRange.intersects(range)) { ranges.set(i, new TextRange(Math.min(currRange.getStartOffset(), range.getStartOffset()), Math.max(currRange.getEndOffset(), range.getEndOffset()))); entries.get(i).add(entry); processed = true; break; } } if (processed) continue; ranges.add(range); entries.add(new SmartList<>(entry)); } // for each set of intersecting ranges, compute the best errors to show for (List<Map.Entry<PsiElement, JsonValidationError>> entryList : entries) { int min = entryList.stream().map(v -> v.getValue().getPriority().ordinal()).min(Integer::compareTo).orElse(Integer.MAX_VALUE); for (Map.Entry<PsiElement, JsonValidationError> entry : entryList) { JsonValidationError validationError = entry.getValue(); PsiElement psiElement = entry.getKey(); if (validationError.getPriority().ordinal() > min) { continue; } TextRange range = myWalker.adjustErrorHighlightingRange(psiElement); range = range.shiftLeft(psiElement.getTextRange().getStartOffset()); registerError(psiElement, range, validationError); } } }