private void rename(final @NotNull XmlTag tag) {
    final Pair<ASTNode, ASTNode> pair = getNamePair(tag);
    if (pair == null) return;

    final Project project = myEditor.getProject();
    if (project != null) {

      final List<TextRange> highlightRanges = new ArrayList<>();
      highlightRanges.add(pair.first.getTextRange());
      if (pair.second != null) {
        highlightRanges.add(pair.second.getTextRange());
      }

      if (!CommonRefactoringUtil.checkReadOnlyStatus(project, tag)) {
        return;
      }

      myHighlighters = new ArrayList<>();

      CommandProcessor.getInstance().executeCommand(project, () -> ApplicationManager.getApplication().runWriteAction(() -> {
        final int offset = myEditor.getCaretModel().getOffset();
        myEditor.getCaretModel().moveToOffset(tag.getTextOffset());

        final Template t = buildTemplate(tag, pair);
        TemplateManager.getInstance(project).startTemplate(myEditor, t, new TemplateEditingAdapter() {
          @Override
          public void templateFinished(final @NotNull Template template, boolean brokenOff) {
            finish();
          }

          @Override
          public void templateCancelled(final Template template) {
            finish();
          }
        }, (variableName, value) -> value.length() == 0 || value.charAt(value.length() - 1) != ' ');

        // restore old offset
        myEditor.getCaretModel().moveToOffset(offset);

        addHighlights(highlightRanges, myEditor, myHighlighters);
      }), RefactoringBundle.message("rename.title"), null);
    }
  }
private void rename(final @NotNull XmlTag tag)