diff --git a/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinMultiFileTestCase.kt b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinMultiFileTestCase.kt index 4270b923489..3df02effb8b 100644 --- a/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinMultiFileTestCase.kt +++ b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/KotlinMultiFileTestCase.kt @@ -17,11 +17,13 @@ package org.jetbrains.kotlin.idea.test import com.intellij.ide.highlighter.ModuleFileType +import com.intellij.openapi.fileEditor.FileDocumentManager import com.intellij.openapi.module.ModuleManager import com.intellij.openapi.vfs.VfsUtilCore import com.intellij.openapi.vfs.VirtualFile import com.intellij.openapi.vfs.VirtualFileVisitor import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess +import com.intellij.psi.PsiDocumentManager import com.intellij.refactoring.MultiFileTestCase import com.intellij.testFramework.PsiTestUtil import org.jetbrains.kotlin.idea.util.application.runWriteAction @@ -35,6 +37,22 @@ abstract class KotlinMultiFileTestCase : MultiFileTestCase() { VfsRootAccess.allowRootAccess(KotlinTestUtils.getHomeDirectory()) } + protected fun getTestDirName(lowercaseFirstLetter : Boolean) : String { + val testName = getTestName(lowercaseFirstLetter) + val endIndex = testName.lastIndexOf('_') + if (endIndex < 0) return testName + return testName.substring(0, endIndex).replace('_', '/') + } + + protected fun doTestCommittingDocuments(action : (VirtualFile, VirtualFile?) -> Unit) { + super.doTest({ rootDir, rootAfter -> + action(rootDir, rootAfter) + + PsiDocumentManager.getInstance(project!!).commitAllDocuments() + FileDocumentManager.getInstance().saveAllDocuments() + }, getTestDirName(true)) + } + override fun prepareProject(rootDir: VirtualFile) { if (isMultiModule) { val model = ModuleManager.getInstance(project).modifiableModel diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractMultiFileInspectionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractMultiFileInspectionTest.kt index 351cd852c01..9e204484153 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractMultiFileInspectionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractMultiFileInspectionTest.kt @@ -85,11 +85,6 @@ abstract class AbstractMultiFileInspectionTest : KotlinMultiFileTestCase() { getTestDirName(true)) } - protected fun getTestDirName(lowercaseFirstLetter : Boolean) : String { - val testName = getTestName(lowercaseFirstLetter) - return testName.substring(0, testName.lastIndexOf('_')).replace('_', '/') - } - override fun getTestRoot() : String { return "/multiFileInspections/" } diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/AbstractMultiModuleMoveTest.kt b/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/AbstractMultiModuleMoveTest.kt index b7c70db05f2..2a4f1574366 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/AbstractMultiModuleMoveTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/move/AbstractMultiModuleMoveTest.kt @@ -16,11 +16,8 @@ package org.jetbrains.kotlin.idea.refactoring.move -import com.intellij.openapi.fileEditor.FileDocumentManager import com.intellij.openapi.module.Module import com.intellij.openapi.module.ModuleManager -import com.intellij.openapi.vfs.VirtualFile -import com.intellij.psi.PsiDocumentManager import org.jetbrains.kotlin.idea.refactoring.rename.loadTestConfiguration import org.jetbrains.kotlin.idea.test.ConfigLibraryUtil import org.jetbrains.kotlin.idea.test.KotlinMultiFileTestCase @@ -71,18 +68,4 @@ abstract class AbstractMultiModuleMoveTest : KotlinMultiFileTestCase() { } } } - - protected fun doTestCommittingDocuments(action : (VirtualFile, VirtualFile?) -> Unit) { - super.doTest({ rootDir, rootAfter -> - action(rootDir, rootAfter) - - PsiDocumentManager.getInstance(project!!).commitAllDocuments() - FileDocumentManager.getInstance().saveAllDocuments() - }, getTestDirName(true)) - } - - protected fun getTestDirName(lowercaseFirstLetter : Boolean) : String { - val testName = getTestName(lowercaseFirstLetter) - return testName.substring(0, testName.indexOf('_')) - } } \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/AbstractMultiModuleRenameTest.kt b/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/AbstractMultiModuleRenameTest.kt index 027b5aa66d7..76d0130d21d 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/AbstractMultiModuleRenameTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/AbstractMultiModuleRenameTest.kt @@ -16,9 +16,6 @@ package org.jetbrains.kotlin.idea.refactoring.rename -import com.intellij.openapi.fileEditor.FileDocumentManager -import com.intellij.openapi.vfs.VirtualFile -import com.intellij.psi.PsiDocumentManager import com.intellij.psi.PsiManager import junit.framework.TestCase import org.jetbrains.kotlin.idea.jsonUtils.getString @@ -51,18 +48,4 @@ abstract class AbstractMultiModuleRenameTest : KotlinMultiFileTestCase() { } } } - - protected fun doTestCommittingDocuments(action : (VirtualFile, VirtualFile?) -> Unit) { - super.doTest({ rootDir, rootAfter -> - action(rootDir, rootAfter) - - PsiDocumentManager.getInstance(project!!).commitAllDocuments() - FileDocumentManager.getInstance().saveAllDocuments() - }, getTestDirName(true)) - } - - protected fun getTestDirName(lowercaseFirstLetter : Boolean) : String { - val testName = getTestName(lowercaseFirstLetter) - return testName.substring(0, testName.indexOf('_')) - } }