Fix compilation on 193 and clean up other warnings
This commit is contained in:
@@ -14,7 +14,6 @@ import com.intellij.codeInspection.LocalInspectionEP
|
|||||||
import com.intellij.ide.highlighter.JavaFileType
|
import com.intellij.ide.highlighter.JavaFileType
|
||||||
import com.intellij.openapi.command.CommandProcessor
|
import com.intellij.openapi.command.CommandProcessor
|
||||||
import com.intellij.openapi.editor.Editor
|
import com.intellij.openapi.editor.Editor
|
||||||
import com.intellij.openapi.extensions.Extensions
|
|
||||||
import com.intellij.openapi.fileTypes.FileType
|
import com.intellij.openapi.fileTypes.FileType
|
||||||
import com.intellij.openapi.fileTypes.PlainTextFileType
|
import com.intellij.openapi.fileTypes.PlainTextFileType
|
||||||
import com.intellij.openapi.util.io.FileUtil
|
import com.intellij.openapi.util.io.FileUtil
|
||||||
@@ -26,7 +25,6 @@ import com.intellij.psi.PsiFile
|
|||||||
import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl
|
import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl
|
||||||
import com.intellij.util.ArrayUtil
|
import com.intellij.util.ArrayUtil
|
||||||
import com.intellij.util.PathUtil
|
import com.intellij.util.PathUtil
|
||||||
import com.intellij.util.containers.ContainerUtil
|
|
||||||
import junit.framework.ComparisonFailure
|
import junit.framework.ComparisonFailure
|
||||||
import junit.framework.TestCase
|
import junit.framework.TestCase
|
||||||
import org.jetbrains.kotlin.idea.KotlinFileType
|
import org.jetbrains.kotlin.idea.KotlinFileType
|
||||||
@@ -49,8 +47,7 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest
|
|||||||
|
|
||||||
if (beforeFileName.endsWith(".test")) {
|
if (beforeFileName.endsWith(".test")) {
|
||||||
doMultiFileTest(beforeFileName)
|
doMultiFileTest(beforeFileName)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
doTest(beforeFileName)
|
doTest(beforeFileName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,15 +62,10 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun enableInspectionTools(klass: Class<*>) {
|
private fun enableInspectionTools(klass: Class<*>) {
|
||||||
val eps = ContainerUtil.newArrayList<InspectionEP>()
|
val eps = mutableListOf<InspectionEP>().apply {
|
||||||
ContainerUtil.addAll<InspectionEP, LocalInspectionEP, List<InspectionEP>>(
|
addAll(LocalInspectionEP.LOCAL_INSPECTION.extensions)
|
||||||
eps,
|
addAll(InspectionEP.GLOBAL_INSPECTION.extensions)
|
||||||
*(@Suppress("DEPRECATION") Extensions.getExtensions(LocalInspectionEP.LOCAL_INSPECTION))
|
}
|
||||||
)
|
|
||||||
ContainerUtil.addAll<InspectionEP, InspectionEP, List<InspectionEP>>(
|
|
||||||
eps,
|
|
||||||
*(@Suppress("DEPRECATION") Extensions.getExtensions(InspectionEP.GLOBAL_INSPECTION))
|
|
||||||
)
|
|
||||||
|
|
||||||
val tool = eps.firstOrNull { it.implementationClass == klass.name }?.instantiateTool()
|
val tool = eps.firstOrNull { it.implementationClass == klass.name }?.instantiateTool()
|
||||||
?: error("Could not find inspection tool for class: $klass")
|
?: error("Could not find inspection tool for class: $klass")
|
||||||
@@ -117,11 +109,11 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun doMultiFileTest(beforeFileName: String) {
|
private fun doMultiFileTest(beforeFileName: String) {
|
||||||
val multifileText = FileUtil.loadFile(File(beforeFileName), true)
|
val multiFileText = FileUtil.loadFile(File(beforeFileName), true)
|
||||||
|
|
||||||
val subFiles = TestFiles.createTestFiles(
|
val subFiles = TestFiles.createTestFiles(
|
||||||
"single.kt",
|
"single.kt",
|
||||||
multifileText,
|
multiFileText,
|
||||||
object : TestFiles.TestFileFactoryNoModules<TestFile>() {
|
object : TestFiles.TestFileFactoryNoModules<TestFile>() {
|
||||||
override fun create(fileName: String, text: String, directives: Map<String, String>): TestFile {
|
override fun create(fileName: String, text: String, directives: Map<String, String>): TestFile {
|
||||||
val linesWithoutDirectives = text.lines().filter {
|
val linesWithoutDirectives = text.lines().filter {
|
||||||
@@ -141,7 +133,7 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
configureMultiFileTest(subFiles, beforeFile)
|
configureMultiFileTest(subFiles, beforeFile)
|
||||||
configureCompilerOptions(multifileText, project, module)
|
configureCompilerOptions(multiFileText, project, module)
|
||||||
|
|
||||||
CommandProcessor.getInstance().executeCommand(project, {
|
CommandProcessor.getInstance().executeCommand(project, {
|
||||||
try {
|
try {
|
||||||
@@ -165,8 +157,8 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest
|
|||||||
TestCase.assertNotNull(".after file should exist", afterFile)
|
TestCase.assertNotNull(".after file should exist", afterFile)
|
||||||
if (afterText != afterFile!!.content) {
|
if (afterText != afterFile!!.content) {
|
||||||
val actualTestFile = StringBuilder()
|
val actualTestFile = StringBuilder()
|
||||||
if (multifileText.startsWith("// LANGUAGE_VERSION")) {
|
if (multiFileText.startsWith("// LANGUAGE_VERSION")) {
|
||||||
actualTestFile.append(multifileText.lineSequence().first())
|
actualTestFile.append(multiFileText.lineSequence().first())
|
||||||
}
|
}
|
||||||
|
|
||||||
actualTestFile.append("// FILE: ").append(beforeFile.path).append("\n").append(beforeFile.content)
|
actualTestFile.append("// FILE: ").append(beforeFile.path).append("\n").append(beforeFile.content)
|
||||||
@@ -177,18 +169,14 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest
|
|||||||
|
|
||||||
KotlinTestUtils.assertEqualsToFile(File(beforeFileName), actualTestFile.toString())
|
KotlinTestUtils.assertEqualsToFile(File(beforeFileName), actualTestFile.toString())
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
TestCase.assertNull(".after file should not exist", afterFile)
|
TestCase.assertNull(".after file should not exist", afterFile)
|
||||||
}
|
}
|
||||||
}
|
} catch (e: ComparisonFailure) {
|
||||||
catch (e: ComparisonFailure) {
|
|
||||||
throw e
|
throw e
|
||||||
}
|
} catch (e: AssertionError) {
|
||||||
catch (e: AssertionError) {
|
|
||||||
throw e
|
throw e
|
||||||
}
|
} catch (e: Throwable) {
|
||||||
catch (e: Throwable) {
|
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
TestCase.fail(getTestName(true))
|
TestCase.fail(getTestName(true))
|
||||||
}
|
}
|
||||||
@@ -234,8 +222,7 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest
|
|||||||
val afterFilePath = beforeFileName.replace(".before.Main.", ".after.")
|
val afterFilePath = beforeFileName.replace(".before.Main.", ".after.")
|
||||||
try {
|
try {
|
||||||
myFixture.checkResultByFile(mainFile.name.replace(".before.Main.", ".after."))
|
myFixture.checkResultByFile(mainFile.name.replace(".before.Main.", ".after."))
|
||||||
}
|
} catch (e: ComparisonFailure) {
|
||||||
catch (e: ComparisonFailure) {
|
|
||||||
KotlinTestUtils.assertEqualsToFile(File(afterFilePath), editor)
|
KotlinTestUtils.assertEqualsToFile(File(afterFilePath), editor)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,24 +234,19 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest
|
|||||||
val afterFile = File(extraFileFullPath.replace(".before.", ".after."))
|
val afterFile = File(extraFileFullPath.replace(".before.", ".after."))
|
||||||
if (afterFile.exists()) {
|
if (afterFile.exists()) {
|
||||||
KotlinTestUtils.assertEqualsToFile(afterFile, file.text)
|
KotlinTestUtils.assertEqualsToFile(afterFile, file.text)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
KotlinTestUtils.assertEqualsToFile(File(extraFileFullPath), file.text)
|
KotlinTestUtils.assertEqualsToFile(File(extraFileFullPath), file.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (e: ComparisonFailure) {
|
||||||
catch (e: ComparisonFailure) {
|
|
||||||
throw e
|
throw e
|
||||||
}
|
} catch (e: AssertionError) {
|
||||||
catch (e: AssertionError) {
|
|
||||||
throw e
|
throw e
|
||||||
}
|
} catch (e: Throwable) {
|
||||||
catch (e: Throwable) {
|
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
TestCase.fail(getTestName(true))
|
TestCase.fail(getTestName(true))
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
if (configured) {
|
if (configured) {
|
||||||
rollbackCompilerOptions(project, module)
|
rollbackCompilerOptions(project, module)
|
||||||
}
|
}
|
||||||
@@ -318,19 +300,19 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest
|
|||||||
if (actionShouldBeAvailable) {
|
if (actionShouldBeAvailable) {
|
||||||
val texts = getActionsTexts(availableActions)
|
val texts = getActionsTexts(availableActions)
|
||||||
val infos = doHighlighting()
|
val infos = doHighlighting()
|
||||||
TestCase.fail("Action with text '" + text + "' is not available in test " + testFilePath + "\n" +
|
TestCase.fail(
|
||||||
|
"Action with text '" + text + "' is not available in test " + testFilePath + "\n" +
|
||||||
"Available actions (" + texts.size + "): \n" +
|
"Available actions (" + texts.size + "): \n" +
|
||||||
StringUtil.join(texts, "\n") +
|
StringUtil.join(texts, "\n") +
|
||||||
"\nActions:\n" +
|
"\nActions:\n" +
|
||||||
StringUtil.join(availableActions, "\n") +
|
StringUtil.join(availableActions, "\n") +
|
||||||
"\nInfos:\n" +
|
"\nInfos:\n" +
|
||||||
StringUtil.join(infos, "\n"))
|
StringUtil.join(infos, "\n")
|
||||||
}
|
)
|
||||||
else {
|
} else {
|
||||||
DirectiveBasedActionUtils.checkAvailableActionsAreExpected(file, availableActions)
|
DirectiveBasedActionUtils.checkAvailableActionsAreExpected(file, availableActions)
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (!actionShouldBeAvailable) {
|
if (!actionShouldBeAvailable) {
|
||||||
TestCase.fail("Action '$text' is available (but must not) in test $testFilePath")
|
TestCase.fail("Action '$text' is available (but must not) in test $testFilePath")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user