<commit_before>package com.intellij.xml.index;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.indexing.DataIndexer;
import com.intellij.util.indexing.FileBasedIndex;
import com.intellij.util.indexing.FileContent;
import com.intellij.util.indexing.ID;
import com.intellij.util.io.DataExternalizer;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.NotNull;

import java.io.ByteArrayInputStream;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author <NAME>
 */
public class XmlNamespaceIndex extends XmlIndex<String>{

  @Nullable
  public static String getNamespace(VirtualFile file, final Project project) {
    final List<String> list = FileBasedIndex.getInstance().getValues(NAME, file.getUrl(), createFilter(project));
    return list.size() == 0 ? null : list.get(0);
  }

  public static Collection<VirtualFile> getFilesByNamespace(String namespace, final Project project) {
    return FileBasedIndex.getInstance().getContainingFiles(NAME, namespace, createFilter(project));
  }
  
  static void requestRebuild() {
    FileBasedIndex.getInstance().requestRebuild(NAME);
  }

  private static final ID<String,String> NAME = ID.create("XmlNamespaces");

  public ID<String, String> getName() {
    return NAME;
  }

  public DataIndexer<String, String, FileContent> getIndexer() {
    return new DataIndexer<String, String, FileContent>() {
      @NotNull
      public Map<String, String> map(final FileContent inputData) {
        final String ns = XsdNamespaceBuilder.computeNamespace(new ByteArrayInputStream(inputData.getContent()));
        final HashMap<String, String> map = new HashMap<String, String>(2);
        if (ns != null) {
          map.put(ns, "");
        }
        map.put(inputData.getFile().getUrl(), ns);
        return map;
      }
    };
  }

  public DataExternalizer<String> getValueExternalizer() {
    return KEY_DESCRIPTOR;
  }
}<commit_msg>IDEADEV-30155<commit_after>package com.intellij.xml.index;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.indexing.DataIndexer;
import com.intellij.util.indexing.FileBasedIndex;
import com.intellij.util.indexing.FileContent;
import com.intellij.util.indexing.ID;
import com.intellij.util.io.DataExternalizer;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.NotNull;

import java.io.ByteArrayInputStream;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author <NAME>
 */
public class XmlNamespaceIndex extends XmlIndex<String>{

  @Nullable
  public static String getNamespace(VirtualFile file, final Project project) {
    final List<String> list = FileBasedIndex.getInstance().getValues(NAME, file.getUrl(), createFilter(project));
    return list.size() == 0 ? null : list.get(0);
  }

  public static Collection<VirtualFile> getFilesByNamespace(String namespace, final Project project) {
    return FileBasedIndex.getInstance().getContainingFiles(NAME, namespace, createFilter(project));
  }
  
  static void requestRebuild() {
    FileBasedIndex.getInstance().requestRebuild(NAME);
  }

  private static final ID<String,String> NAME = ID.create("XmlNamespaces");

  public ID<String, String> getName() {
    return NAME;
  }

  public DataIndexer<String, String, FileContent> getIndexer() {
    return new DataIndexer<String, String, FileContent>() {
      @NotNull
      public Map<String, String> map(final FileContent inputData) {
        final String ns = XsdNamespaceBuilder.computeNamespace(new ByteArrayInputStream(inputData.getContent()));
        final HashMap<String, String> map = new HashMap<String, String>(2);
        if (ns != null) {
          map.put(ns, "");
        }
        map.put(inputData.getFile().getUrl(), ns == null ? "" : ns);
        return map;
      }
    };
  }

  public DataExternalizer<String> getValueExternalizer() {
    return KEY_DESCRIPTOR;
  }
}
{'fraction_non_alphanumeric': 0.11740196078431372, 'fraction_numerical': 0.002696078431372549, 'mean_word_length': 4.42686170212766, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '5449162', 'n_tokens_mistral': 1231, 'n_tokens_neox': 1204, 'n_words': 256}