<commit_before>/*
 * Copyright (c) 2000-2006 JetBrains s.r.o. All Rights Reserved.
 */

package com.intellij.uiDesigner;

import com.intellij.ide.util.TreeFileChooser;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.util.containers.HashSet;
import org.jetbrains.annotations.Nullable;

import javax.imageio.ImageIO;
import java.util.Arrays;
import java.util.Set;

/**
 * @author yole
 */
public class ImageFileFilter implements TreeFileChooser.PsiFileFilter {
  private Set<String> myExtensions;
  private GlobalSearchScope myModuleScope;

  public ImageFileFilter(@Nullable Module module) {
    myExtensions = new HashSet<String>(Arrays.asList(ImageIO.getReaderFormatNames()));
    if (module != null) {
      myModuleScope = module.getModuleWithDependenciesAndLibrariesScope(true);
    }
  }

  public boolean accept(PsiFile file) {
    final VirtualFile virtualFile = file.getVirtualFile();
    return virtualFile != null &&
           myExtensions.contains(virtualFile.getExtension()) &&
           (myModuleScope == null || myModuleScope.contains(virtualFile));
  }
}
<commit_msg>compare filename extensions case-insensitively (IDEADEV-9105)<commit_after>/*
 * Copyright (c) 2000-2006 JetBrains s.r.o. All Rights Reserved.
 */

package com.intellij.uiDesigner;

import com.intellij.ide.util.TreeFileChooser;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.util.containers.HashSet;
import org.jetbrains.annotations.Nullable;

import javax.imageio.ImageIO;
import java.util.Arrays;
import java.util.Set;

/**
 * @author yole
 */
public class ImageFileFilter implements TreeFileChooser.PsiFileFilter {
  private Set<String> myExtensions;
  private GlobalSearchScope myModuleScope;

  public ImageFileFilter(@Nullable Module module) {
    final String[] formatNames = ImageIO.getReaderFormatNames();
    for(int i=0; i<formatNames.length; i++) {
      formatNames [i] = formatNames [i].toLowerCase();
    }
    myExtensions = new HashSet<String>(Arrays.asList(formatNames));
    if (module != null) {
      myModuleScope = module.getModuleWithDependenciesAndLibrariesScope(true);
    }
  }

  public boolean accept(PsiFile file) {
    final VirtualFile virtualFile = file.getVirtualFile();
    if (virtualFile != null) {
      String extension = virtualFile.getExtension();
      return extension != null &&
             myExtensions.contains(extension.toLowerCase()) &&
             (myModuleScope == null || myModuleScope.contains(virtualFile));
    }
    return false;
  }
}

{'fraction_non_alphanumeric': 0.11070911722141824, 'fraction_numerical': 0.007597684515195369, 'mean_word_length': 4.442913385826771, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 7, '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': '5526042', 'n_tokens_mistral': 853, 'n_tokens_neox': 830, 'n_words': 166}