<commit_before>package com.intellij.compiler;

import com.intellij.openapi.compiler.*;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.testFramework.IdeaTestCase;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Chunk;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;

/**
 * @author <NAME>
 *         Date: Dec 3, 2007
 */
public class CompilerOrderingTest extends IdeaTestCase {
  public void testOrdering() {
    final CompilerManager manager = CompilerManager.getInstance(myProject);
    TranslatingCompiler c1 = new MockCompiler("C1");
    TranslatingCompiler c2 = new MockCompiler("C2");
    TranslatingCompiler c3 = new MockCompiler("C3");
    TranslatingCompiler c4 = new MockCompiler("C4");
    
    manager.addTranslatingCompiler(
      c1, 
      new HashSet<FileType>(Arrays.asList(StdFileTypes.HTML)), new HashSet<FileType>(Arrays.asList(StdFileTypes.JAVA))
    );
    manager.addTranslatingCompiler(
      c2, 
      new HashSet<FileType>(Arrays.asList(StdFileTypes.JSP)), new HashSet<FileType>(Arrays.asList(StdFileTypes.HTML))
    );
    manager.addTranslatingCompiler(
      c3, 
      new HashSet<FileType>(Arrays.asList(StdFileTypes.CLASS)), new HashSet<FileType>(Arrays.asList(StdFileTypes.IDEA_PROJECT))
    );
    manager.addTranslatingCompiler(
      c4, 
      new HashSet<FileType>(Arrays.asList(StdFileTypes.ARCHIVE)), new HashSet<FileType>(Arrays.asList(StdFileTypes.HTML, StdFileTypes.JAVA))
    );
    
    
    compareDescriptions(new String[] {
      CompilerBundle.message("resource.compiler.description"),
      //"groovy compiler",
      "C2",
      "C4",
      "C1",
      CompilerBundle.message("annotation.processing.compiler.description"), 
      CompilerBundle.message("java.compiler.description"),
      "C3"
    }, manager.getCompilers(TranslatingCompiler.class));
  }

  private void compareDescriptions(final String[] expected, final TranslatingCompiler[] compilers) {
    List<String> actualDescriptions = new ArrayList<String>();
    for (TranslatingCompiler compiler : compilers) {
      actualDescriptions.add(compiler.getDescription());
    }
    final String[] actual = (String[])ArrayUtil.toStringArray(actualDescriptions);

    assertEquals(expected.length, actual.length);<commit_msg>redundant casts: cleanup<commit_after>package com.intellij.compiler;

import com.intellij.openapi.compiler.*;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.testFramework.IdeaTestCase;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Chunk;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;

/**
 * @author <NAME>
 *         Date: Dec 3, 2007
 */
public class CompilerOrderingTest extends IdeaTestCase {
  public void testOrdering() {
    final CompilerManager manager = CompilerManager.getInstance(myProject);
    TranslatingCompiler c1 = new MockCompiler("C1");
    TranslatingCompiler c2 = new MockCompiler("C2");
    TranslatingCompiler c3 = new MockCompiler("C3");
    TranslatingCompiler c4 = new MockCompiler("C4");
    
    manager.addTranslatingCompiler(
      c1, 
      new HashSet<FileType>(Arrays.asList(StdFileTypes.HTML)), new HashSet<FileType>(Arrays.asList(StdFileTypes.JAVA))
    );
    manager.addTranslatingCompiler(
      c2, 
      new HashSet<FileType>(Arrays.asList(StdFileTypes.JSP)), new HashSet<FileType>(Arrays.asList(StdFileTypes.HTML))
    );
    manager.addTranslatingCompiler(
      c3, 
      new HashSet<FileType>(Arrays.asList(StdFileTypes.CLASS)), new HashSet<FileType>(Arrays.asList(StdFileTypes.IDEA_PROJECT))
    );
    manager.addTranslatingCompiler(
      c4, 
      new HashSet<FileType>(Arrays.asList(StdFileTypes.ARCHIVE)), new HashSet<FileType>(Arrays.asList(StdFileTypes.HTML, StdFileTypes.JAVA))
    );
    
    
    compareDescriptions(new String[] {
      CompilerBundle.message("resource.compiler.description"),
      //"groovy compiler",
      "C2",
      "C4",
      "C1",
      CompilerBundle.message("annotation.processing.compiler.description"), 
      CompilerBundle.message("java.compiler.description"),
      "C3"
    }, manager.getCompilers(TranslatingCompiler.class));
  }

  private void compareDescriptions(final String[] expected, final TranslatingCompiler[] compilers) {
    List<String> actualDescriptions = new ArrayList<String>();
    for (TranslatingCompiler compiler : compilers) {
      actualDescriptions.add(compiler.getDescription());
    }
    final String[] actual = ArrayUtil.toStringArray(actualDescriptions);

    assertEquals(expected.length, actual.length);
{'fraction_non_alphanumeric': 0.11678977839888201, 'fraction_numerical': 0.008384907167099222, 'mean_word_length': 4.499451152579583, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '938268', 'n_tokens_mistral': 1552, 'n_tokens_neox': 1508, 'n_words': 245}