QuickFixTest: all inspections should be initialized from EP
This commit is contained in:
@@ -6,7 +6,6 @@
|
|||||||
package org.jetbrains.kotlin.idea.quickfix
|
package org.jetbrains.kotlin.idea.quickfix
|
||||||
|
|
||||||
import com.intellij.codeInspection.InspectionProfileEntry
|
import com.intellij.codeInspection.InspectionProfileEntry
|
||||||
import com.intellij.codeInspection.LocalInspectionTool
|
|
||||||
import com.intellij.openapi.util.io.FileUtil
|
import com.intellij.openapi.util.io.FileUtil
|
||||||
import com.intellij.testFramework.InspectionTestUtil
|
import com.intellij.testFramework.InspectionTestUtil
|
||||||
import org.jetbrains.kotlin.idea.quickfix.utils.findInspectionFile
|
import org.jetbrains.kotlin.idea.quickfix.utils.findInspectionFile
|
||||||
@@ -16,24 +15,20 @@ import java.io.File
|
|||||||
interface QuickFixTest {
|
interface QuickFixTest {
|
||||||
fun parseInspectionsToEnable(beforeFileName: String, beforeFileText: String): List<InspectionProfileEntry> {
|
fun parseInspectionsToEnable(beforeFileName: String, beforeFileText: String): List<InspectionProfileEntry> {
|
||||||
val toolsStrings = InTextDirectivesUtils.findListWithPrefixes(beforeFileText, "TOOL:")
|
val toolsStrings = InTextDirectivesUtils.findListWithPrefixes(beforeFileText, "TOOL:")
|
||||||
if (toolsStrings.isNotEmpty()) {
|
val profiles = try {
|
||||||
return toolsStrings.map { toolFqName ->
|
if (toolsStrings.isNotEmpty()) toolsStrings.map { toolFqName ->
|
||||||
try {
|
@Suppress("UNCHECKED_CAST")
|
||||||
val aClass = Class.forName(toolFqName)
|
Class.forName(toolFqName) as Class<InspectionProfileEntry>
|
||||||
return@map aClass.newInstance() as LocalInspectionTool
|
} else {
|
||||||
} catch (e: Exception) {
|
val inspectionFile = findInspectionFile(File(beforeFileName).parentFile) ?: return emptyList()
|
||||||
throw IllegalArgumentException("Failed to create inspection for key '$toolFqName'", e)
|
val className = FileUtil.loadFile(inspectionFile).trim { it <= ' ' }
|
||||||
}
|
@Suppress("UNCHECKED_CAST") val inspectionClass = Class.forName(className) as Class<InspectionProfileEntry>
|
||||||
|
listOf(inspectionClass)
|
||||||
}
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
throw IllegalArgumentException("Failed to create inspections", e)
|
||||||
}
|
}
|
||||||
|
|
||||||
val inspectionFile = findInspectionFile(File(beforeFileName).parentFile)
|
return InspectionTestUtil.instantiateTools(profiles)
|
||||||
if (inspectionFile != null) {
|
|
||||||
val className = FileUtil.loadFile(inspectionFile).trim { it <= ' ' }
|
|
||||||
@Suppress("UNCHECKED_CAST") val inspectionClass = Class.forName(className) as Class<InspectionProfileEntry>
|
|
||||||
return InspectionTestUtil.instantiateTools(listOf(inspectionClass))
|
|
||||||
}
|
|
||||||
|
|
||||||
return emptyList()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user