AbstractQuickFixTest: FORCE_PACKAGE_FOLDER directive added

It was added as workaround for IDEA-176033 (IDEA-176032 in particular)
This commit is contained in:
Nicolay Mitropolsky
2017-10-26 14:09:48 +03:00
committed by Nikolay Krasko
parent ab0c081897
commit 6cb556dd6b
3 changed files with 24 additions and 2 deletions
@@ -70,6 +70,13 @@ abstract class AbstractQuickFixTest : KotlinLightCodeInsightFixtureTestCase() {
}
private fun getPathAccordingToPackage(name: String, text: String): String {
val packagePath = text.lines().let { it.find { it.trim().startsWith("package") } }
?.removePrefix("package")
?.trim()?.replace(".", "/") ?: ""
return packagePath + "/" + name
}
private fun doKotlinQuickFixTest(beforeFileName: String) {
val testFile = File(beforeFileName)
CommandProcessor.getInstance().executeCommand(project, {
@@ -87,13 +94,22 @@ abstract class AbstractQuickFixTest : KotlinLightCodeInsightFixtureTestCase() {
expectedErrorMessage = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// SHOULD_FAIL_WITH: ")
val contents = StringUtil.convertLineSeparators(fileText)
myFixture.configureByText(testFile.canonicalFile.name, contents)
var filePath = testFile.canonicalFile.name
val putIntoPackageFolder = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// FORCE_PACKAGE_FOLDER") != null
if (putIntoPackageFolder) {
filePath = getPathAccordingToPackage(filePath, contents)
myFixture.addFileToProject(filePath, contents)
myFixture.configureByFile(filePath)
}
else {
myFixture.configureByText(filePath, contents)
}
checkForUnexpectedActions()
configExtra(fileText)
applyAction(contents, testFile.canonicalPath)
applyAction(contents, filePath)
UsefulTestCase.assertEmpty(expectedErrorMessage)
}
@@ -3,6 +3,9 @@
// CONFIGURE_SPRING_FILE_SET
// WITH_RUNTIME
// DISABLE-ERRORS
// FORCE_PACKAGE_FOLDER
package pkg
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component
@@ -3,6 +3,9 @@
// CONFIGURE_SPRING_FILE_SET
// WITH_RUNTIME
// DISABLE-ERRORS
// FORCE_PACKAGE_FOLDER
package pkg
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component