boolean (@NotNull DocumentEx document, @NotNull TextRange range, @NotNull List<? super RangeMarker> hardRefToRangeMarkers) { int start = range.getStartOffset(); int end = range.getEndOffset(); if (!document.processRangeMarkersOverlappingWith(start, end, rm -> !areConflicting(range, rm.getTextRange()))) { return false; } RangeMarker marker = document.createRangeMarker(start, end); hardRefToRangeMarkers.add(marker); //prevent immediate GC return true; }