private void orderTemplateVariables(Template template) {
    if (myVariableComparator == null || !(template instanceof TemplateImpl templateImpl)) {
      return;
    }

    List<Variable> variables = new ArrayList<>(templateImpl.getVariables());
    variables.sort(myVariableComparator);
    for (int i = variables.size() - 1; i >= 0; i--) {
      templateImpl.removeVariable(i);
    }
    for (Variable variable : variables) {
      templateImpl.addVariable(variable);
    }
  }
private void orderTemplateVariables(Template template)