OccurrencesChooser<PsiExpression> (Editor editor) { return new OccurrencesChooser<>(editor) { @Override protected TextRange getOccurrenceRange(PsiExpression occurrence) { RangeMarker rangeMarker = occurrence.getUserData(ElementToWorkOn.TEXT_RANGE); if (rangeMarker != null) { return rangeMarker.getTextRange(); } return occurrence.getTextRange(); } }; }