void (@NotNull ReplacementInfo info) { final PsiElement firstElement = StructuralSearchUtil.getPresentableElement(info.getMatch(0)); if (firstElement == null) return; final PsiFile file = firstElement.getContainingFile(); final FileViewProvider fileViewProvider = file.getViewProvider(); final Document document = fileViewProvider.getDocument(); assert document != null; final TextRange range = firstElement.getTextRange(); int startOffset = range.getStartOffset(); int endOffset = range.getEndOffset(); final int count = info.getMatchesCount(); for (int i = 1; i < count; i++) { final PsiElement match = info.getMatch(i); if (match == null) { continue; } final TextRange range1 = match.getTextRange(); startOffset = Math.min(startOffset, range1.getStartOffset()); endOffset = Math.max(endOffset, range1.getEndOffset()); } final RangeMarker rangeMarker = document.createRangeMarker(startOffset, endOffset); rangeMarker.setGreedyToLeft(true); rangeMarker.setGreedyToRight(true); myRangeMarkers.put(info, rangeMarker); }