private static void addToConfig(@NotNull Project project, @NotNull List<PsiElement> config, @NotNull UntaintedConfiguration context) {
    UntaintedConfiguration previousContext = context.copy();
    InspectionProfileModifiableModelKt.modifyAndCommitProjectProfile(project, model -> {
      for (PsiElement element : config) {
        if (element instanceof JvmMethod jvmMethod) {
          JvmClass containingClass = jvmMethod.getContainingClass();
          if (containingClass == null) continue;
          context.getMethodClass().add(containingClass.getQualifiedName());
          context.getMethodNames().add(jvmMethod.getName());
        }
        if (element instanceof JvmField jvmField) {
          JvmClass containingClass = jvmField.getContainingClass();
          if (containingClass == null) continue;
          context.getFieldClass().add(containingClass.getQualifiedName());
          context.getFieldNames().add(jvmField.getName());
        }
      }
    });

    UntaintedConfiguration newContext = context.copy();

    UndoManager.getInstance(project).undoableActionPerformed(new BasicUndoableAction() {
      @Override
      public void undo() {
        InspectionProfileModifiableModelKt.modifyAndCommitProjectProfile(project, model -> {
          copyContext(context, previousContext);
        });
      }

      @Override
      public void redo() {
        InspectionProfileModifiableModelKt.modifyAndCommitProjectProfile(project, model -> {
          copyContext(context, newContext);
        });
      }

      private static void copyContext(@NotNull UntaintedConfiguration context, UntaintedConfiguration newContext) {
        context.getMethodNames().clear();
        context.getMethodClass().clear();
        context.getFieldClass().clear();
        context.getFieldNames().clear();
        context.getMethodNames().addAll(newContext.getMethodNames());
        context.getMethodClass().addAll(newContext.getMethodClass());
        context.getFieldNames().addAll(newContext.getFieldNames());
        context.getFieldClass().addAll(newContext.getFieldClass());
      }
    });
  }
private static void addToConfig(@NotNull Project project, @NotNull List<PsiElement> config, @NotNull UntaintedConfiguration context)