javac ast indices: enumerate file path as case insensitive
authorDmitry Batkovich <dmitry.batkovich@jetbrains.com>
Thu, 13 Oct 2016 20:46:28 +0000 (23:46 +0300)
committerDmitry Batkovich <dmitry.batkovich@jetbrains.com>
Thu, 13 Oct 2016 20:46:28 +0000 (23:46 +0300)
jps/jps-builders/src/org/jetbrains/jps/backwardRefs/CompilerBackwardReferenceIndex.java
jps/jps-builders/testSrc/org/jetbrains/references/ReferenceIndexTestBase.kt

index aa4a3fddabb3f567126b3a883cba383fb263b6e8..f603863a38cbb9174a8304ba10d9aec631457b30 100644 (file)
  */
 package org.jetbrains.jps.backwardRefs;
 
+import com.intellij.openapi.util.SystemInfo;
 import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.util.CommonProcessors;
 import com.intellij.util.Processor;
 import com.intellij.util.io.*;
 import gnu.trove.THashSet;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 import org.jetbrains.jps.builders.java.dependencyView.CloseableMaplet;
 import org.jetbrains.jps.builders.java.dependencyView.CollectionFactory;
 import org.jetbrains.jps.builders.java.dependencyView.IntObjectPersistentMultiMaplet;
@@ -29,6 +31,7 @@ import org.jetbrains.jps.builders.storage.BuildDataCorruptedException;
 
 import java.io.*;
 import java.util.Collection;
+import java.util.Locale;
 
 public class CompilerBackwardReferenceIndex {
   private static final int VERSION = 0;
@@ -66,7 +69,12 @@ public class CompilerBackwardReferenceIndex {
       if (versionDiffers(buildDir)) {
         FileUtil.writeToFile(new File(myIndicesDir, VERSION_FILE), String.valueOf(VERSION));
       }
-      myFilePathEnumerator = new PersistentStringEnumerator(new File(myIndicesDir, FILE_ENUM_TAB));
+      myFilePathEnumerator = new PersistentStringEnumerator(new File(myIndicesDir, FILE_ENUM_TAB)) {
+        @Override
+        public int enumerate(@Nullable String value) throws IOException {
+          return super.enumerate(SystemInfo.isFileSystemCaseSensitive ? value : value.toLowerCase(Locale.ROOT));
+        }
+      };
 
       final KeyDescriptor<LightUsage> lightUsageDescriptor = LightUsage.createDescriptor();
       final KeyDescriptor<LightDefinition> defDescriptor = LightDefinition.createDescriptor(lightUsageDescriptor);
index 600c8e73ffdad421ca3e971af9d90489e5b81ff5..eb90ba4a97713d53700dd2935d754e3cda4c2d65 100644 (file)
@@ -17,8 +17,10 @@ package org.jetbrains.references
 
 import com.intellij.openapi.util.io.FileUtil
 import com.intellij.openapi.vfs.CharsetToolkit
+import com.intellij.testFramework.UsefulTestCase
 import com.intellij.util.PathUtil
 import com.sun.tools.javac.util.Convert
+import junit.framework.TestCase
 import org.jetbrains.jps.backwardRefs.BackwardReferenceIndexWriter
 import org.jetbrains.jps.backwardRefs.ByteArrayEnumerator
 import org.jetbrains.jps.backwardRefs.CompilerBackwardReferenceIndex
@@ -66,7 +68,9 @@ abstract class ReferenceIndexTestBase : JpsBuildTestCase() {
 
 
   protected fun assertIndexEquals(expectedIndexDumpFile: String) {
-    assertSameLinesWithFile(testDataRootPath + "/" + getTestName(true) + "/" + expectedIndexDumpFile, indexAsText())
+    val expectedIndex = FileUtil.loadFile(File(testDataRootPath + "/" + getTestName(true) + "/" + expectedIndexDumpFile), CharsetToolkit.UTF8_CHARSET)
+    val actualIndex = indexAsText()
+    TestCase.assertTrue(String.CASE_INSENSITIVE_ORDER.compare(expectedIndex, actualIndex) == 0)
   }
 
   protected fun indexAsText(): String {