Settings (@NotNull GrIntroduceContext context) { // Add occurrences highlighting ArrayList<RangeHighlighter> highlighters = new ArrayList<>(); HighlightManager highlightManager = null; if (context.getEditor() != null) { highlightManager = HighlightManager.getInstance(context.getProject()); if (context.getOccurrences().length > 1) { highlightManager.addOccurrenceHighlights(context.getEditor(), context.getOccurrences(), EditorColors.SEARCH_RESULT_ATTRIBUTES, true, highlighters); } } GrIntroduceDialog<Settings> dialog = getDialog(context); dialog.show(); if (dialog.isOK()) { if (context.getEditor() != null) { for (RangeHighlighter highlighter : highlighters) { highlightManager.removeSegmentHighlighter(context.getEditor(), highlighter); } } return dialog.getSettings(); } else { if (context.getOccurrences().length > 1) { WindowManager.getInstance().getStatusBar(context.getProject()) .setInfo(GroovyRefactoringBundle.message("press.escape.to.remove.the.highlighting")); } } return null; }