as32: Update to 181 platform api

This commit is contained in:
Vyacheslav Gerasimov
2018-05-10 18:00:56 +03:00
parent ab25145458
commit 4adc0a94ab
11 changed files with 530 additions and 149 deletions
@@ -54,7 +54,7 @@ class KotlinCallerChooser(
previousTree: Tree?,
callback: Consumer<Set<PsiElement>>
): CallerChooserBase<PsiElement>(declaration, project, title, previousTree, "dummy." + KotlinFileType.EXTENSION, callback) {
override fun createTreeNode(method: PsiElement?, called: com.intellij.util.containers.HashSet<PsiElement>, cancelCallback: Runnable): KotlinMethodNode {
override fun createTreeNode(method: PsiElement, called: HashSet<PsiElement>, cancelCallback: Runnable): KotlinMethodNode {
return KotlinMethodNode(method, called, myProject, cancelCallback)
}
@@ -8,13 +8,13 @@ package org.jetbrains.kotlin.idea.configuration
import com.intellij.openapi.util.io.FileUtil
import org.junit.Assert
import java.io.File
import java.io.IOException
import java.nio.file.Path
abstract class AbstractConfigureKotlinInTempDirTest : AbstractConfigureKotlinTest() {
@Throws(IOException::class)
override fun getIprFile(): File {
override fun getProjectDirOrFile(): Path {
val tempDir = FileUtil.generateRandomTemporaryPath()
FileUtil.createTempDirectory("temp", null)
myFilesToDelete.add(tempDir)
FileUtil.copyDir(File(projectRoot), tempDir)
@@ -24,8 +24,9 @@ abstract class AbstractConfigureKotlinInTempDirTest : AbstractConfigureKotlinTes
if (!File(projectFilePath).exists()) {
val dotIdeaPath = projectRoot + "/.idea"
Assert.assertTrue("Project file or '.idea' dir should exists in " + projectRoot, File(dotIdeaPath).exists())
return File(projectRoot)
return File(projectRoot).toPath()
}
return File(projectFilePath)
return File(projectFilePath).toPath()
}
}
@@ -35,7 +35,7 @@ import org.jetbrains.kotlin.idea.framework.KotlinSdkType
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
import org.jetbrains.kotlin.utils.PathUtil
import java.io.File
import java.io.IOException
import java.nio.file.Path
abstract class AbstractConfigureKotlinTest : PlatformTestCase() {
override fun setUp() {
@@ -126,16 +126,14 @@ abstract class AbstractConfigureKotlinTest : PlatformTestCase() {
val modules: Array<Module>
get() = ModuleManager.getInstance(myProject).modules
@Throws(IOException::class)
override fun getIprFile(): File {
override fun getProjectDirOrFile(): Path {
val projectFilePath = projectRoot + "/projectFile.ipr"
TestCase.assertTrue("Project file should exists " + projectFilePath, File(projectFilePath).exists())
return File(projectFilePath)
return File(projectFilePath).toPath()
}
@Throws(Exception::class)
override fun doCreateProject(projectFile: File): Project? {
return myProjectManager.loadProject(projectFile.path)
override fun doCreateProject(projectFile: Path): Project {
return myProjectManager.loadProject(projectFile.toFile().path)!!
}
private val projectName: String
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.idea.configuration
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.impl.ApplicationImpl
import com.intellij.openapi.util.io.FileUtil
import org.jetbrains.kotlin.config.ApiVersion
import org.jetbrains.kotlin.config.KotlinFacetSettingsProvider
import org.jetbrains.kotlin.config.LanguageVersion
@@ -25,13 +26,15 @@ import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCommonCompilerArgu
import org.jetbrains.kotlin.idea.project.getLanguageVersionSettings
import org.jetbrains.kotlin.idea.project.languageVersionSettings
import org.junit.Assert
import java.io.File
import java.io.IOException
import java.nio.file.Path
open class ConfigureKotlinInTempDirTest : AbstractConfigureKotlinInTempDirTest() {
@Throws(IOException::class)
fun testNoKotlincExistsNoSettingsRuntime10() {
val application = ApplicationManager.getApplication() as ApplicationImpl
application.doNotSave(false)
application.isSaveAllowed = true
Assert.assertEquals(LanguageVersion.KOTLIN_1_0, module.languageVersionSettings.languageVersion)
Assert.assertEquals(LanguageVersion.KOTLIN_1_0, myProject.getLanguageVersionSettings(null).languageVersion)
application.saveAll()
@@ -40,7 +43,7 @@ open class ConfigureKotlinInTempDirTest : AbstractConfigureKotlinInTempDirTest()
fun testNoKotlincExistsNoSettingsLatestRuntime() {
val application = ApplicationManager.getApplication() as ApplicationImpl
application.doNotSave(false)
application.isSaveAllowed = true
Assert.assertEquals(LanguageVersion.LATEST_STABLE, module.languageVersionSettings.languageVersion)
Assert.assertEquals(LanguageVersion.LATEST_STABLE, myProject.getLanguageVersionSettings(null).languageVersion)
application.saveAll()
@@ -49,7 +52,7 @@ open class ConfigureKotlinInTempDirTest : AbstractConfigureKotlinInTempDirTest()
fun testKotlincExistsNoSettingsLatestRuntimeNoVersionAutoAdvance() {
val application = ApplicationManager.getApplication() as ApplicationImpl
application.doNotSave(false)
application.isSaveAllowed = true
Assert.assertEquals(LanguageVersion.LATEST_STABLE, module.languageVersionSettings.languageVersion)
Assert.assertEquals(LanguageVersion.LATEST_STABLE, myProject.getLanguageVersionSettings(null).languageVersion)
KotlinCommonCompilerArgumentsHolder.getInstance(project).update {
@@ -62,7 +65,7 @@ open class ConfigureKotlinInTempDirTest : AbstractConfigureKotlinInTempDirTest()
fun testDropKotlincOnVersionAutoAdvance() {
val application = ApplicationManager.getApplication() as ApplicationImpl
application.doNotSave(false)
application.isSaveAllowed = true
Assert.assertEquals(LanguageVersion.LATEST_STABLE, module.languageVersionSettings.languageVersion)
KotlinCommonCompilerArgumentsHolder.getInstance(project).update {
autoAdvanceLanguageVersion = true
@@ -97,7 +100,7 @@ open class ConfigureKotlinInTempDirTest : AbstractConfigureKotlinInTempDirTest()
fun testLoadAndSaveProjectWithV2FacetConfig() {
val moduleFileContentBefore = String(module.moduleFile!!.contentsToByteArray())
val application = ApplicationManager.getApplication() as ApplicationImpl
application.doNotSave(false)
application.isSaveAllowed = true
application.saveAll()
val moduleFileContentAfter = String(module.moduleFile!!.contentsToByteArray())
Assert.assertEquals(moduleFileContentBefore, moduleFileContentAfter)
@@ -39,15 +39,28 @@ import org.junit.Assert
class CommonIntentionActionsTest : LightPlatformCodeInsightFixtureTestCase() {
private class SimpleMethodRequest(
project: Project,
override val methodName: String,
override val modifiers: Collection<JvmModifier> = emptyList(),
override val returnType: ExpectedTypes = emptyList(),
override val annotations: Collection<AnnotationRequest> = emptyList(),
override val parameters: List<ExpectedParameter> = emptyList(),
override val targetSubstitutor: JvmSubstitutor = PsiJvmSubstitutor(project, PsiSubstitutor.EMPTY)
project: Project,
private val methodName: String,
private val modifiers: Collection<JvmModifier> = emptyList(),
private val returnType: ExpectedTypes = emptyList(),
private val annotations: Collection<AnnotationRequest> = emptyList(),
private val parameters: List<Pair<SuggestedNameInfo, List<ExpectedType>>> = emptyList(),
private val targetSubstitutor: JvmSubstitutor = PsiJvmSubstitutor(project, PsiSubstitutor.EMPTY)
) : CreateMethodRequest {
override val isValid: Boolean = true
override fun getTargetSubstitutor(): JvmSubstitutor = targetSubstitutor
override fun getModifiers() = modifiers
override fun getMethodName() = methodName
override fun getAnnotations() = annotations
override fun getParameters() = parameters
override fun getReturnType() = returnType
override fun isValid(): Boolean = true
}
private class NameInfo(vararg names: String) : SuggestedNameInfo(names)