AbstractQuickFixTest: FORCE_PACKAGE_FOLDER directive added
It was added as workaround for IDEA-176033 (IDEA-176032 in particular)
This commit is contained in:
committed by
Nikolay Krasko
parent
ab0c081897
commit
6cb556dd6b
@@ -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) {
|
private fun doKotlinQuickFixTest(beforeFileName: String) {
|
||||||
val testFile = File(beforeFileName)
|
val testFile = File(beforeFileName)
|
||||||
CommandProcessor.getInstance().executeCommand(project, {
|
CommandProcessor.getInstance().executeCommand(project, {
|
||||||
@@ -87,13 +94,22 @@ abstract class AbstractQuickFixTest : KotlinLightCodeInsightFixtureTestCase() {
|
|||||||
|
|
||||||
expectedErrorMessage = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// SHOULD_FAIL_WITH: ")
|
expectedErrorMessage = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// SHOULD_FAIL_WITH: ")
|
||||||
val contents = StringUtil.convertLineSeparators(fileText)
|
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()
|
checkForUnexpectedActions()
|
||||||
|
|
||||||
configExtra(fileText)
|
configExtra(fileText)
|
||||||
|
|
||||||
applyAction(contents, testFile.canonicalPath)
|
applyAction(contents, filePath)
|
||||||
|
|
||||||
UsefulTestCase.assertEmpty(expectedErrorMessage)
|
UsefulTestCase.assertEmpty(expectedErrorMessage)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
// CONFIGURE_SPRING_FILE_SET
|
// CONFIGURE_SPRING_FILE_SET
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
// DISABLE-ERRORS
|
// DISABLE-ERRORS
|
||||||
|
// FORCE_PACKAGE_FOLDER
|
||||||
|
|
||||||
|
package pkg
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired
|
import org.springframework.beans.factory.annotation.Autowired
|
||||||
import org.springframework.stereotype.Component
|
import org.springframework.stereotype.Component
|
||||||
|
|||||||
+3
@@ -3,6 +3,9 @@
|
|||||||
// CONFIGURE_SPRING_FILE_SET
|
// CONFIGURE_SPRING_FILE_SET
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
// DISABLE-ERRORS
|
// DISABLE-ERRORS
|
||||||
|
// FORCE_PACKAGE_FOLDER
|
||||||
|
|
||||||
|
package pkg
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired
|
import org.springframework.beans.factory.annotation.Autowired
|
||||||
import org.springframework.stereotype.Component
|
import org.springframework.stereotype.Component
|
||||||
|
|||||||
Reference in New Issue
Block a user