<commit_before>// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.file.exclude;

import com.intellij.openapi.components.State;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.indexing.FileBasedIndex;
import org.jetbrains.annotations.NotNull;

/**
 * @author <NAME>
 */
@State(name = "ProjectPlainTextFileTypeManager")
public class ProjectPlainTextFileTypeManager extends PersistentFileSetManager {

  public static ProjectPlainTextFileTypeManager getInstance(@NotNull Project project) {
    return project.getService(ProjectPlainTextFileTypeManager.class);
  }

  @Override
  protected void onFileAdded(@NotNull VirtualFile file) {
    FileBasedIndex.getInstance().requestReindex(file);
  }

  @Override
  protected void onFileRemoved(@NotNull VirtualFile file) {
    FileBasedIndex.getInstance().requestReindex(file);
  }
}<commit_msg>enforced plain text manager should not invalidate indexes for plain text files if it's already did<commit_after>// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.file.exclude;

import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.State;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.search.FileTypeIndex;
import com.intellij.util.indexing.FileBasedIndex;
import org.jetbrains.annotations.NotNull;

/**
 * @author <NAME>
 */
@State(name = "ProjectPlainTextFileTypeManager")
public class ProjectPlainTextFileTypeManager extends PersistentFileSetManager {
  @NotNull
  private final Project myProject;

  public ProjectPlainTextFileTypeManager(@NotNull Project project) {
    myProject = project;
  }

  public static ProjectPlainTextFileTypeManager getInstance(@NotNull Project project) {
    return project.getService(ProjectPlainTextFileTypeManager.class);
  }

  @Override
  protected void onFileAdded(@NotNull VirtualFile file) {
    ApplicationManager.getApplication().assertReadAccessAllowed();
    if (FileTypeIndex.getIndexedFileType(file, myProject) != EnforcedPlainTextFileType.INSTANCE) {
      FileBasedIndex.getInstance().requestReindex(file);
    }
  }

  @Override
  protected void onFileRemoved(@NotNull VirtualFile file) {
    FileBasedIndex.getInstance().requestReindex(file);
  }
}
{'fraction_non_alphanumeric': 0.08770555990602975, 'fraction_numerical': 0.007830853563038372, 'mean_word_length': 5.602067183462532, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '264321', 'n_tokens_mistral': 751, 'n_tokens_neox': 709, 'n_words': 171}