private static @NotNull ModUpdateFileText getRevertModCommand(@NotNull Editor editor, String oldName) {
    TemplateState state = TemplateManagerImpl.getTemplateState(editor);
    int segmentsCount = state == null ? 0 : state.getSegmentsCount();
    Document document = editor.getDocument();
    String oldText = document.getText();
    StringBuilder newText = new StringBuilder();
    int lastPos = 0;
    List<ModUpdateFileText.Fragment> fragments = new ArrayList<>();
    for (int i = 0; i < segmentsCount; i++) {
      TextRange segmentRange = state.getSegmentRange(i);
      newText.append(oldText, lastPos, segmentRange.getStartOffset());
      fragments.add(new ModUpdateFileText.Fragment(newText.length(), segmentRange.getLength(), oldName.length()));
      newText.append(oldName);
      lastPos = segmentRange.getEndOffset();
    }
    newText.append(oldText, lastPos, oldText.length());
    return new ModUpdateFileText(editor.getVirtualFile(), oldText, newText.toString(), fragments);
  }
private static @NotNull ModUpdateFileText getRevertModCommand(@NotNull Editor editor, String oldName)