boolean (@NotNull List<? extends ResultItem> items, @NotNull ResultItem newItem) { TextRange newItemTextRange = null; //noinspection ForLoopReplaceableByForEach for (int i = 0; i < items.size(); i++) { ResultItem item = items.get(i); if (item.getHyperlinkInfo() != null) { if (newItemTextRange == null) { newItemTextRange = new TextRange(newItem.getHighlightStartOffset(), newItem.getHighlightEndOffset()); } if (newItemTextRange.intersectsStrict(item.getHighlightStartOffset(), item.getHighlightEndOffset())) { return true; } } } return false; }