public static void addDecorator(@NotNull PyFunction function, @NotNull String decorator) {
    final PyDecoratorList currentDecorators = function.getDecoratorList();

    final List<String> decoTexts = new ArrayList<>();
    decoTexts.add(decorator);
    if (currentDecorators != null) {
      for (PyDecorator deco : currentDecorators.getDecorators()) {
        decoTexts.add(deco.getText());
      }
    }

    final PyElementGenerator generator = PyElementGenerator.getInstance(function.getProject());
    final PyDecoratorList newDecorators = generator.createDecoratorList(ArrayUtilRt.toStringArray(decoTexts));

    if (currentDecorators != null) {
      currentDecorators.replace(newDecorators);
    }
    else {
      function.addBefore(newDecorators, function.getFirstChild());
    }
  }
public static void addDecorator(@NotNull PyFunction function, @NotNull String decorator)