<commit_before>package com.intellij.facet.impl;

import com.intellij.facet.FacetConfiguration;
import com.intellij.facet.FacetType;
import com.intellij.facet.FacetManagerImpl;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.ProjectComponent;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.openapi.module.impl.RemoveInvalidElementsDialog;
import com.intellij.util.xmlb.annotations.MapAnnotation;
import com.intellij.util.xmlb.annotations.Tag;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;

import java.util.*;

/**
 * @author nik
 */
@State(
    name = ProjectFacetManagerImpl.COMPONENT_NAME,
    storages = {
        @Storage(
            id="other",
            file="$PROJECT_FILE$"
        )
    }
)
public class ProjectFacetManagerImpl extends ProjectFacetManagerEx implements ProjectComponent, PersistentStateComponent<ProjectFacetManagerImpl.ProjectFacetManagerState> {
  @NonNls public static final String COMPONENT_NAME = "ProjectFacetManager";
  private static final Logger LOG = Logger.getInstance("#com.intellij.facet.impl.ProjectFacetManagerImpl");
  private ProjectFacetManagerState myState = new ProjectFacetManagerState();
  private final List<FacetLoadingErrorDescription> myFacetLoadingErrors = new ArrayList<FacetLoadingErrorDescription>();
  private final Project myProject;

  public ProjectFacetManagerImpl(Project project) {
    myProject = project;
  }

  public void projectOpened() {
    if (!myFacetLoadingErrors.isEmpty()) {
      Application application = ApplicationManager.getApplication();
      if (application.isHeadlessEnvironment()) {
        throw new RuntimeException(myFacetLoadingErrors.get(0).getDescription());
      }

      Runnable runnable = new Runnable() {
        public void run() {
          Collection<FacetLoadingErrorDescription> toRemove =
              RemoveInvalidElementsDialog.showDialog(myProject, ProjectBundle.message("dialog.title.cannot.load.facets"),
                                                     ProjectBundle.message("error.message.cannot.load.facets"),
                                                     ProjectBundle.message("confirmation.message.would.you.like.to.remove.facet"),
                                                     myFacetLoadingErrors);
          myFacetLoadingErrors.clear();
          for (FacetLoadingErrorDescription errorDescription : toRemove) {
            FacetManagerImpl manager = (FacetManagerImpl)FacetManagerImpl.getInstance(errorDescription.getModule());
            manager.removeInvalidFacet(errorDescription.getUnderlyingFacet(), errorDescription.getState());
          }
        }
      };
      application.invokeLater(runnable, ModalityState.NON_MODAL);
    }
  }

  public void projectClosed() {
  }
<commit_msg>IDEADEV-24258<commit_after>package com.intellij.facet.impl;

import com.intellij.facet.FacetConfiguration;
import com.intellij.facet.FacetType;
import com.intellij.facet.FacetManagerImpl;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.ProjectComponent;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.openapi.module.impl.RemoveInvalidElementsDialog;
import com.intellij.util.xmlb.annotations.MapAnnotation;
import com.intellij.util.xmlb.annotations.Tag;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;

import java.util.*;

/**
 * @author nik
 */
@State(
    name = ProjectFacetManagerImpl.COMPONENT_NAME,
    storages = {
        @Storage(
            id="other",
            file="$PROJECT_FILE$"
        )
    }
)
public class ProjectFacetManagerImpl extends ProjectFacetManagerEx implements ProjectComponent, PersistentStateComponent<ProjectFacetManagerImpl.ProjectFacetManagerState> {
  @NonNls public static final String COMPONENT_NAME = "ProjectFacetManager";
  private static final Logger LOG = Logger.getInstance("#com.intellij.facet.impl.ProjectFacetManagerImpl");
  private ProjectFacetManagerState myState = new ProjectFacetManagerState();
  private final List<FacetLoadingErrorDescription> myFacetLoadingErrors = new ArrayList<FacetLoadingErrorDescription>();
  private final Project myProject;

  public ProjectFacetManagerImpl(Project project) {
    myProject = project;
  }

  public void projectOpened() {
    if (!myFacetLoadingErrors.isEmpty()) {
      Application application = ApplicationManager.getApplication();
      if (application.isHeadlessEnvironment()) {
        throw new RuntimeException(myFacetLoadingErrors.get(0).getDescription());
      }

      Runnable runnable = new Runnable() {
        public void run() {
          List<FacetLoadingErrorDescription> errorDescriptions = new ArrayList<FacetLoadingErrorDescription>();
          for (FacetLoadingErrorDescription errorDescription : myFacetLoadingErrors) {
            if (!errorDescription.getModule().isDisposed()) {
              errorDescriptions.add(errorDescription);
            }
          }
          myFacetLoadingErrors.clear();

          if (!errorDescriptions.isEmpty()) {
            Collection<FacetLoadingErrorDescription> toRemove =
                RemoveInvalidElementsDialog.showDialog(myProject, ProjectBundle.message("dialog.title.cannot.load.facets"),
                                                       ProjectBundle.message("error.message.cannot.load.facets"),
                                                       ProjectBundle.message("confirmation.message.would.you.like.to.remove.facet"),
                                                       errorDescriptions);
            for (FacetLoadingErrorDescription errorDescription : toRemove) {
              FacetManagerImpl manager = (FacetManagerImpl)FacetManagerImpl.getInstance(errorDescription.getModule());
              manager.removeInvalidFacet(errorDescription.getUnderlyingFacet(), errorDescription.getState());
            }
          }
        }
      };
      application.invokeLater(runnable, ModalityState.NON_MODAL);
    }
  }

  public void projectClosed() {
  }

{'fraction_non_alphanumeric': 0.09120383422610658, 'fraction_numerical': 0.0009867493656611221, 'mean_word_length': 3.6739130434782608, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5527518', 'n_tokens_mistral': 1895, 'n_tokens_neox': 1863, 'n_words': 289}