void (@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { int[] starts = editor.getSelectionModel().getBlockSelectionStarts(); int[] ends = editor.getSelectionModel().getBlockSelectionEnds(); final Document document = editor.getDocument(); XmlFile xmlFile = (XmlFile)file; Int2ObjectMap<String> map = computeMap(xmlFile); for (int i = starts.length - 1; i >= 0; i--) { final int start = starts[i]; final int end = ends[i]; String oldText = document.getText(new TextRange(start, end)); final String newText = escape(xmlFile, map, oldText, start); if (!oldText.equals(newText)) { document.replaceString(start, end, newText); } } }