as40: Fix test compilation for AS 4.0 C7
This commit is contained in:
+1
-1
@@ -155,7 +155,7 @@ public class KotlinConfidenceTest extends LightCompletionTestCase {
|
||||
new CodeCompletionHandlerBase(CompletionType.BASIC, false, true, true).invokeCompletion(
|
||||
getProject(), getEditor(), 0, false);
|
||||
|
||||
LookupImpl lookup = (LookupImpl) LookupManager.getActiveLookup(myEditor);
|
||||
LookupImpl lookup = (LookupImpl) LookupManager.getActiveLookup(getEditor());
|
||||
myItems = lookup == null ? null : lookup.getItems().toArray(LookupElement.EMPTY_ARRAY);
|
||||
myPrefix = lookup == null ? null : lookup.itemPattern(lookup.getItems().get(0));
|
||||
}
|
||||
|
||||
+3
-3
@@ -31,7 +31,7 @@ import org.gradle.tooling.model.DomainObjectSet;
|
||||
import org.gradle.tooling.model.idea.IdeaModule;
|
||||
import org.gradle.util.GradleVersion;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.gradle.model.ClassSetProjectImportExtraModelProvider;
|
||||
import org.jetbrains.plugins.gradle.model.ClassSetProjectImportModelProvider;
|
||||
import org.jetbrains.plugins.gradle.model.ExternalProject;
|
||||
import org.jetbrains.plugins.gradle.model.ProjectImportAction;
|
||||
import org.jetbrains.plugins.gradle.service.execution.GradleExecutionHelper;
|
||||
@@ -141,7 +141,7 @@ public abstract class AbstractModelBuilderTest {
|
||||
|
||||
try {
|
||||
ProjectImportAction projectImportAction = new ProjectImportAction(false);
|
||||
projectImportAction.addProjectImportExtraModelProvider(new ClassSetProjectImportExtraModelProvider(getModels()));
|
||||
projectImportAction.addProjectImportModelProvider(new ClassSetProjectImportModelProvider(getModels()));
|
||||
BuildActionExecuter<ProjectImportAction.AllModels> buildActionExecutor = connection.action(projectImportAction);
|
||||
File initScript = GradleExecutionHelper.generateInitScript(false, getToolingExtensionClasses());
|
||||
assertNotNull(initScript);
|
||||
@@ -196,7 +196,7 @@ public abstract class AbstractModelBuilderTest {
|
||||
Map<String, T> map = ContainerUtil.map2Map(ideaModules, new Function<IdeaModule, Pair<String, T>>() {
|
||||
@Override
|
||||
public Pair<String, T> fun(IdeaModule module) {
|
||||
T value = allModels.getExtraProject(module, aClass);
|
||||
T value = allModels.getModel(module, aClass);
|
||||
String key = value != null ? module.getGradleProject().getPath() : filterKey;
|
||||
return Pair.create(key, value);
|
||||
}
|
||||
|
||||
+8
-10
@@ -14,26 +14,24 @@ import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.testFramework.LightIdeaTestCase
|
||||
import com.intellij.testFramework.LightPlatformCodeInsightTestCase
|
||||
import com.intellij.testFramework.LightPlatformTestCase
|
||||
|
||||
// BUNCH: as36, 191
|
||||
@Suppress("DEPRECATION")
|
||||
@Deprecated("Use KotlinLightCodeInsightFixtureTestCase instead")
|
||||
abstract class KotlinLightCodeInsightTestCase : com.intellij.testFramework.LightCodeInsightTestCase() {
|
||||
protected inline val project_: Project get() = LightPlatformTestCase.getProject()
|
||||
protected inline val module_: Module get() = LightPlatformTestCase.getModule()
|
||||
protected inline val editor_: Editor get() = LightPlatformCodeInsightTestCase.getEditor()
|
||||
protected inline val file_: PsiFile get() = LightPlatformCodeInsightTestCase.getFile()
|
||||
protected inline val currentEditorDataContext_: DataContext get() = LightPlatformCodeInsightTestCase.getCurrentEditorDataContext()
|
||||
protected inline val project_: Project get() = project
|
||||
protected inline val module_: Module get() = module
|
||||
protected inline val editor_: Editor get() = editor
|
||||
protected inline val file_: PsiFile get() = file
|
||||
protected inline val currentEditorDataContext_: DataContext get() = currentEditorDataContext
|
||||
|
||||
protected fun configureFromFileText_(fileName: String, fileText: String): Document {
|
||||
return LightPlatformCodeInsightTestCase.configureFromFileText(fileName, fileText, false)
|
||||
return configureFromFileText(fileName, fileText, false)
|
||||
}
|
||||
}
|
||||
|
||||
// BUNCH: as36, 191
|
||||
abstract class KotlinLightIdeaTestCase : LightIdeaTestCase() {
|
||||
protected inline val project_: Project get() = LightPlatformTestCase.getProject()
|
||||
protected inline val module_: Module get() = LightPlatformTestCase.getModule()
|
||||
protected inline val project_: Project get() = project
|
||||
protected inline val module_: Module get() = module
|
||||
}
|
||||
+3
-4
@@ -10,7 +10,6 @@ import com.intellij.debugger.streams.wrapper.StreamChainBuilder
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.projectRoots.Sdk
|
||||
import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable
|
||||
import com.intellij.testFramework.LightPlatformTestCase
|
||||
import com.intellij.testFramework.PsiTestUtil
|
||||
import junit.framework.TestCase
|
||||
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
|
||||
@@ -34,18 +33,18 @@ abstract class KotlinPsiChainBuilderTestCase(private val relativePath: String) :
|
||||
super.setUp()
|
||||
ApplicationManager.getApplication().runWriteAction {
|
||||
@Suppress("UnstableApiUsage")
|
||||
if (ProjectLibraryTable.getInstance(LightPlatformTestCase.getProject()).getLibraryByName(stdLibName) == null) {
|
||||
if (ProjectLibraryTable.getInstance(project).getLibraryByName(stdLibName) == null) {
|
||||
val stdLibPath = ForTestCompileRuntime.runtimeJarForTests()
|
||||
PsiTestUtil.addLibrary(
|
||||
testRootDisposable,
|
||||
LightPlatformTestCase.getModule(),
|
||||
module,
|
||||
stdLibName,
|
||||
stdLibPath.parent,
|
||||
stdLibPath.name
|
||||
)
|
||||
}
|
||||
}
|
||||
LibraryModificationTracker.getInstance(LightPlatformTestCase.getProject()).incModificationCount()
|
||||
LibraryModificationTracker.getInstance(project).incModificationCount()
|
||||
}
|
||||
|
||||
|
||||
|
||||
+6
-10
@@ -16,7 +16,6 @@ import com.intellij.openapi.application.runWriteAction
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction
|
||||
import com.intellij.openapi.extensions.Extensions
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.testFramework.LightPlatformCodeInsightTestCase
|
||||
import junit.framework.ComparisonFailure
|
||||
import junit.framework.TestCase
|
||||
import org.jetbrains.kotlin.formatter.FormatSettingsUtil
|
||||
@@ -42,7 +41,7 @@ abstract class AbstractMoveStatementTest : AbstractCodeMoverTest() {
|
||||
val movers = Extensions.getExtensions(StatementUpDownMover.STATEMENT_UP_DOWN_MOVER_EP)
|
||||
val info = StatementUpDownMover.MoveInfo()
|
||||
val actualMover = movers.firstOrNull {
|
||||
it.checkAvailable(LightPlatformCodeInsightTestCase.getEditor(), LightPlatformCodeInsightTestCase.getFile(), info, direction == "down")
|
||||
it.checkAvailable(editor, file, info, direction == "down")
|
||||
} ?: error("No mover found")
|
||||
|
||||
assertEquals("Unmatched movers", defaultMoverClass.name, actualMover::class.java.name)
|
||||
@@ -53,7 +52,7 @@ abstract class AbstractMoveStatementTest : AbstractCodeMoverTest() {
|
||||
|
||||
abstract class AbstractMoveLeftRightTest : AbstractCodeMoverTest() {
|
||||
protected fun doTest(path: String) {
|
||||
doTest(path) { _, _ -> }
|
||||
doTest(path) { _, _ -> }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,8 +72,7 @@ abstract class AbstractCodeMoverTest : KotlinLightCodeInsightTestCase() {
|
||||
configureByFile(path)
|
||||
|
||||
val fileText = FileUtil.loadFile(File(path), true)
|
||||
val direction = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// MOVE: ")
|
||||
?: error("No MOVE directive found")
|
||||
val direction = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// MOVE: ") ?: error("No MOVE directive found")
|
||||
|
||||
val action = when (direction) {
|
||||
"up" -> MoveStatementUpAction()
|
||||
@@ -112,16 +110,14 @@ abstract class AbstractCodeMoverTest : KotlinLightCodeInsightTestCase() {
|
||||
TestCase.assertEquals(isApplicableExpected, !actionDoesNothing)
|
||||
|
||||
if (isApplicableExpected) {
|
||||
val afterFilePath = path + ".after"
|
||||
val afterFilePath = "$path.after"
|
||||
try {
|
||||
checkResultByFile(afterFilePath)
|
||||
}
|
||||
catch (e: ComparisonFailure) {
|
||||
} catch (e: ComparisonFailure) {
|
||||
KotlinTestUtils.assertEqualsToFile(File(afterFilePath), editor)
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
codeStyleSettings.clearCodeStyleSettings()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,8 +191,10 @@ class InplaceRenameTest : LightPlatformCodeInsightTestCase() {
|
||||
val element = file.findElementForRename<KtNameReferenceExpression>(editor.caretModel.offset)!!
|
||||
assertNotNull(element)
|
||||
|
||||
val dataContext = SimpleDataContext.getSimpleContext(CommonDataKeys.PSI_ELEMENT.name, element,
|
||||
getCurrentEditorDataContext())
|
||||
val dataContext = SimpleDataContext.getSimpleContext(
|
||||
CommonDataKeys.PSI_ELEMENT.name, element,
|
||||
getCurrentEditorDataContext()
|
||||
)
|
||||
val handler = RenameKotlinImplicitLambdaParameter()
|
||||
|
||||
assertTrue(handler.isRenaming(dataContext), "In-place rename not allowed for " + element)
|
||||
@@ -231,25 +233,23 @@ class InplaceRenameTest : LightPlatformCodeInsightTestCase() {
|
||||
private fun doTestInplaceRename(newName: String?, handler: VariableInplaceRenameHandler = KotlinVariableInplaceRenameHandler()) {
|
||||
configureByFile(getTestName(false) + ".kt")
|
||||
val element = TargetElementUtil.findTargetElement(
|
||||
myEditor,
|
||||
editor,
|
||||
TargetElementUtil.ELEMENT_NAME_ACCEPTED or TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED
|
||||
)
|
||||
|
||||
assertNotNull(element)
|
||||
|
||||
val dataContext = SimpleDataContext.getSimpleContext(CommonDataKeys.PSI_ELEMENT.name, element!!,
|
||||
getCurrentEditorDataContext())
|
||||
val dataContext = SimpleDataContext.getSimpleContext(CommonDataKeys.PSI_ELEMENT.name, element!!, currentEditorDataContext)
|
||||
|
||||
if (newName == null) {
|
||||
assertFalse(handler.isRenaming(dataContext), "In-place rename is allowed for " + element)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
try {
|
||||
assertTrue(handler.isRenaming(dataContext), "In-place rename not allowed for " + element)
|
||||
CodeInsightTestUtil.doInlineRename(handler, newName, getEditor(), element)
|
||||
checkResultByFile(getTestName(false) + ".kt.after")
|
||||
} catch (e: BaseRefactoringProcessor.ConflictsInTestsException) {
|
||||
val expectedMessage = InTextDirectivesUtils.findStringWithPrefixes(myFile.text, "// SHOULD_FAIL_WITH: ")
|
||||
val expectedMessage = InTextDirectivesUtils.findStringWithPrefixes(file.text, "// SHOULD_FAIL_WITH: ")
|
||||
TestCase.assertEquals(expectedMessage, e.messages.joinToString())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user