Report error on incompatible .kotlin_module files in classpath

Also remove obsolete test wrongAbiVersionNoErrors

 #KT-25973 Fixed
 #KT-26266 Open
This commit is contained in:
Alexander Udalov
2018-08-17 19:01:26 +02:00
parent 4f11812668
commit 852760b3b0
19 changed files with 105 additions and 90 deletions
@@ -45,11 +45,13 @@ object KotlinJvmModuleAnnotationsIndex : FileBasedIndexExtension<String, List<Cl
override fun getIndexer(): DataIndexer<String, List<ClassId>, FileContent> = DataIndexer { inputData ->
val file = inputData.file
try {
val moduleMapping = ModuleMapping.loadModuleMapping(inputData.content, file.toString(), DeserializationConfiguration.Default)
return@DataIndexer mapOf(file.nameWithoutExtension to moduleMapping.moduleData.annotations.map(ClassId::fromString))
val moduleMapping = ModuleMapping.loadModuleMapping(inputData.content, file.toString(), DeserializationConfiguration.Default) {}
if (moduleMapping !== ModuleMapping.EMPTY) {
return@DataIndexer mapOf(file.nameWithoutExtension to moduleMapping.moduleData.annotations.map(ClassId::fromString))
}
} catch (e: Exception) {
// Exceptions are already reported in KotlinModuleMappingIndex
emptyMap()
}
emptyMap()
}
}
@@ -73,20 +73,19 @@ object KotlinModuleMappingIndex : FileBasedIndexExtension<String, PackageParts>(
override fun getVersion(): Int = 5
override fun getIndexer(): DataIndexer<String, PackageParts, FileContent> {
return DataIndexer<String, PackageParts, FileContent> { inputData ->
val content = inputData.content
val file = inputData.file
try {
val moduleMapping = ModuleMapping.loadModuleMapping(content, file.toString(), DeserializationConfiguration.Default)
if (moduleMapping === ModuleMapping.CORRUPTED) {
file.refresh(true, false)
}
return@DataIndexer moduleMapping.packageFqName2Parts
override fun getIndexer(): DataIndexer<String, PackageParts, FileContent> = DataIndexer { inputData ->
val content = inputData.content
val file = inputData.file
try {
val moduleMapping = ModuleMapping.loadModuleMapping(content, file.toString(), DeserializationConfiguration.Default) {
// Do nothing; it's OK for an IDE index to just ignore incompatible module files
}
catch(e: Exception) {
throw RuntimeException("Error on indexing $file", e)
if (moduleMapping === ModuleMapping.CORRUPTED) {
file.refresh(true, false)
}
return@DataIndexer moduleMapping.packageFqName2Parts
} catch (e: Exception) {
throw RuntimeException("Error on indexing $file", e)
}
}
}