diff --git a/plugins/kotlin/analysis/src/org/jetbrains/kotlin/idea/facet/KotlinVersionInfoProvider.kt b/plugins/kotlin/analysis/src/org/jetbrains/kotlin/idea/facet/KotlinVersionInfoProvider.kt index 3969711d169a..5bf1a44cd390 100644 --- a/plugins/kotlin/analysis/src/org/jetbrains/kotlin/idea/facet/KotlinVersionInfoProvider.kt +++ b/plugins/kotlin/analysis/src/org/jetbrains/kotlin/idea/facet/KotlinVersionInfoProvider.kt @@ -9,7 +9,6 @@ import com.intellij.util.text.VersionComparatorUtil import org.jetbrains.kotlin.config.ApiVersion import org.jetbrains.kotlin.config.KotlinFacetSettingsProvider import org.jetbrains.kotlin.config.LanguageVersion -import org.jetbrains.kotlin.config.VersionView import org.jetbrains.kotlin.idea.compiler.configuration.Version import org.jetbrains.kotlin.platform.IdePlatformKind import org.jetbrains.kotlin.platform.idePlatformKind @@ -78,6 +77,7 @@ fun getDefaultLanguageLevel( fun String?.toLanguageVersion(): LanguageVersion = when { this == null -> LanguageVersion.LATEST_STABLE + startsWith("1.7") -> LanguageVersion.KOTLIN_1_7 startsWith("1.6") -> LanguageVersion.KOTLIN_1_6 startsWith("1.5") -> LanguageVersion.KOTLIN_1_5 startsWith("1.4") -> LanguageVersion.KOTLIN_1_4 diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/asJava/classes/AbstractUltraLightClassSanityTest.kt b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/asJava/classes/AbstractUltraLightClassSanityTest.kt index 20b7896dc4df..b3c8f3ca57c1 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/asJava/classes/AbstractUltraLightClassSanityTest.kt +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/asJava/classes/AbstractUltraLightClassSanityTest.kt @@ -12,7 +12,7 @@ import org.jetbrains.kotlin.test.InTextDirectivesUtils import java.io.File abstract class AbstractUltraLightClassSanityTest : KotlinLightCodeInsightFixtureTestCase() { - override fun getProjectDescriptor(): LightProjectDescriptor = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE + override fun getProjectDescriptor(): LightProjectDescriptor = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE_WITH_STDLIB_JDK8 fun doTest(testDataPath: String) { val ioFile = File(testDataPath) diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/caches/resolve/AbstractIdeLightClassTest.kt b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/caches/resolve/AbstractIdeLightClassTest.kt index ad4fbb04db6c..e7a50ad2fd66 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/caches/resolve/AbstractIdeLightClassTest.kt +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/caches/resolve/AbstractIdeLightClassTest.kt @@ -53,7 +53,12 @@ abstract class AbstractIdeLightClassTest : KotlinLightCodeInsightFixtureTestCase else -> error("Invalid test data extension") } - withCustomCompilerOptions(File(testDataPath, fileName).readText(), project, module) { + val fileText = File(testDataPath, fileName).readText() + if (InTextDirectivesUtils.isDirectiveDefined(fileText, "SKIP_IDE_TEST")) { + return + } + + withCustomCompilerOptions(fileText, project, module) { val testFiles = if (File(testDataPath, extraFilePath).isFile) listOf(fileName, extraFilePath) else listOf(fileName) val lazinessMode = lazinessModeByFileText() myFixture.configureByFiles(*testFiles.toTypedArray()) @@ -90,7 +95,7 @@ abstract class AbstractIdeLightClassTest : KotlinLightCodeInsightFixtureTestCase } } - override fun getProjectDescriptor() = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE + override fun getProjectDescriptor() = KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE_WITH_STDLIB_JDK8 open val fileExtension = ".kt" } @@ -105,7 +110,7 @@ abstract class AbstractIdeCompiledLightClassTest : KotlinDaemonAnalyzerTestCase( val testFile = listOf(File(testDataDir, "$testName.kt"), File(testDataDir, "$testName.kts")).first { it.exists() } ?: error("Test file not found!") - val extraClasspath = mutableListOf(KotlinArtifacts.instance.jetbrainsAnnotations) + val extraClasspath = mutableListOf(KotlinArtifacts.instance.jetbrainsAnnotations, KotlinArtifacts.instance.kotlinStdlibJdk8) if (testFile.extension == "kts") { extraClasspath += KotlinArtifacts.instance.kotlinScriptRuntime } diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/stubs/AbstractResolveByStubTest.kt b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/stubs/AbstractResolveByStubTest.kt index 6c52ec36c759..8ffcf33c2a15 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/stubs/AbstractResolveByStubTest.kt +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/stubs/AbstractResolveByStubTest.kt @@ -8,15 +8,12 @@ import com.intellij.testFramework.IdeaTestUtil import com.intellij.testFramework.LightProjectDescriptor import org.jetbrains.kotlin.idea.artifacts.KotlinArtifacts import org.jetbrains.kotlin.idea.caches.resolve.findModuleDescriptor -import org.jetbrains.kotlin.idea.test.AstAccessControl -import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase -import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor +import org.jetbrains.kotlin.idea.test.* +import org.jetbrains.kotlin.idea.test.util.DescriptorValidator.ValidationVisitor.errorTypesForbidden +import org.jetbrains.kotlin.idea.test.util.RecursiveDescriptorComparator import org.jetbrains.kotlin.load.java.descriptors.PossiblyExternalAnnotationDescriptor import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.KtFile -import org.jetbrains.kotlin.idea.test.InTextDirectivesUtils -import org.jetbrains.kotlin.idea.test.util.DescriptorValidator.ValidationVisitor.errorTypesForbidden -import org.jetbrains.kotlin.idea.test.util.RecursiveDescriptorComparator import org.junit.Assert import java.io.File @@ -45,7 +42,10 @@ abstract class AbstractResolveByStubTest : KotlinLightCodeInsightFixtureTestCase private fun performTest(path: String) { val file = file as KtFile - val module = file.findModuleDescriptor() + + val module = withCustomCompilerOptions(file.text, project, module) { + file.findModuleDescriptor() + } val packageViewDescriptor = module.getPackage(FqName("test")) Assert.assertFalse(packageViewDescriptor.isEmpty()) diff --git a/plugins/kotlin/project-wizard/cli/test/org/jetbrains/kotlin/tools/projectWizard/cli/AbstractBuildFileGenerationTest.kt b/plugins/kotlin/project-wizard/cli/test/org/jetbrains/kotlin/tools/projectWizard/cli/AbstractBuildFileGenerationTest.kt index 12a223c9d9b7..d810b3bdf1ee 100644 --- a/plugins/kotlin/project-wizard/cli/test/org/jetbrains/kotlin/tools/projectWizard/cli/AbstractBuildFileGenerationTest.kt +++ b/plugins/kotlin/project-wizard/cli/test/org/jetbrains/kotlin/tools/projectWizard/cli/AbstractBuildFileGenerationTest.kt @@ -6,7 +6,6 @@ import com.intellij.testFramework.UsefulTestCase import org.jetbrains.kotlin.tools.projectWizard.core.div import org.jetbrains.kotlin.tools.projectWizard.core.service.Services import org.jetbrains.kotlin.tools.projectWizard.phases.GenerationPhase -import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.KotlinPlugin import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.Repositories import org.jetbrains.kotlin.tools.projectWizard.wizard.Wizard import java.nio.file.Files @@ -48,8 +47,7 @@ abstract class AbstractBuildFileGenerationTest : UsefulTestCase() { if (testParameters.keepKotlinVersion) { fileContent } else { - val pluginVersion = wizard.context.read { KotlinPlugin.version.propertyValue.version.toString() } - fileContent.replace(pluginVersion, KOTLIN_VERSION_PLACEHOLDER) + fileContent.replace(KotlinVersionProviderTestWizardService.TEST_KOTLIN_VERSION.toString(), KOTLIN_VERSION_PLACEHOLDER) }.also { it.replaceAllTo( listOf(Repositories.JETBRAINS_KOTLIN_DEV.url), KOTLIN_REPO_PLACEHOLDER diff --git a/plugins/kotlin/project-wizard/cli/test/org/jetbrains/kotlin/tools/projectWizard/cli/KotlinVersionProviderTestWizardService.kt b/plugins/kotlin/project-wizard/cli/test/org/jetbrains/kotlin/tools/projectWizard/cli/KotlinVersionProviderTestWizardService.kt index e69de29bb2d1..5eeb3dc60b48 100644 --- a/plugins/kotlin/project-wizard/cli/test/org/jetbrains/kotlin/tools/projectWizard/cli/KotlinVersionProviderTestWizardService.kt +++ b/plugins/kotlin/project-wizard/cli/test/org/jetbrains/kotlin/tools/projectWizard/cli/KotlinVersionProviderTestWizardService.kt @@ -0,0 +1,27 @@ +// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. + +package org.jetbrains.kotlin.tools.projectWizard.cli + +import org.jetbrains.kotlin.tools.projectWizard.Versions +import org.jetbrains.kotlin.tools.projectWizard.core.service.EapVersionDownloader +import org.jetbrains.kotlin.tools.projectWizard.core.service.WizardKotlinVersion +import org.jetbrains.kotlin.tools.projectWizard.core.service.KotlinVersionKind +import org.jetbrains.kotlin.tools.projectWizard.core.service.KotlinVersionProviderService +import org.jetbrains.kotlin.tools.projectWizard.plugins.kotlin.ProjectKind +import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.* + +class KotlinVersionProviderTestWizardService : KotlinVersionProviderService(), TestWizardService { + override fun getKotlinVersion(projectKind: ProjectKind): WizardKotlinVersion = + kotlinVersionWithDefaultValues( + when (projectKind) { + ProjectKind.COMPOSE -> Versions.KOTLIN_VERSION_FOR_COMPOSE + else -> TEST_KOTLIN_VERSION + } + ) + + companion object { + val TEST_KOTLIN_VERSION by lazy { + EapVersionDownloader.getLatestEapVersion()!! + } + } +} diff --git a/plugins/kotlin/project-wizard/cli/test/org/jetbrains/kotlin/tools/projectWizard/cli/TestWizardService.kt b/plugins/kotlin/project-wizard/cli/test/org/jetbrains/kotlin/tools/projectWizard/cli/TestWizardService.kt index 448b2ce28b9f..7c32a32b3b50 100644 --- a/plugins/kotlin/project-wizard/cli/test/org/jetbrains/kotlin/tools/projectWizard/cli/TestWizardService.kt +++ b/plugins/kotlin/project-wizard/cli/test/org/jetbrains/kotlin/tools/projectWizard/cli/TestWizardService.kt @@ -6,10 +6,16 @@ import org.jetbrains.kotlin.tools.projectWizard.core.service.Services import org.jetbrains.kotlin.tools.projectWizard.core.service.ServicesManager import org.jetbrains.kotlin.tools.projectWizard.core.service.WizardService -interface TestWizardService : WizardService +interface TestWizardService : WizardService { + companion object { + val SERVICES = listOf( + KotlinVersionProviderTestWizardService() + ) + } +} val CLI_WIZARD_TEST_SERVICES_MANAGER = ServicesManager( - Services.IDEA_INDEPENDENT_SERVICES + Services.IDEA_INDEPENDENT_SERVICES + TestWizardService.SERVICES ) { services -> services.firstOrNull { it is TestWizardService } ?: services.firstOrNull() } \ No newline at end of file diff --git a/plugins/kotlin/project-wizard/cli/testData/projectTemplatesBuildFileGeneration/composeDesktopApplication/importParameters.txt b/plugins/kotlin/project-wizard/cli/testData/projectTemplatesBuildFileGeneration/composeDesktopApplication/importParameters.txt index 29c7591c308f..f98b8dca2f3c 100644 --- a/plugins/kotlin/project-wizard/cli/testData/projectTemplatesBuildFileGeneration/composeDesktopApplication/importParameters.txt +++ b/plugins/kotlin/project-wizard/cli/testData/projectTemplatesBuildFileGeneration/composeDesktopApplication/importParameters.txt @@ -1,2 +1 @@ -// runForGradleGroovy false -// keepKotlinVersion true \ No newline at end of file +// runForGradleGroovy false \ No newline at end of file diff --git a/plugins/kotlin/project-wizard/core/src/org/jetbrains/kotlin/tools/projectWizard/core/service/EapVersionDownloader.kt b/plugins/kotlin/project-wizard/core/src/org/jetbrains/kotlin/tools/projectWizard/core/service/EapVersionDownloader.kt index 45ef37a2c78b..e01a3ed3fa46 100644 --- a/plugins/kotlin/project-wizard/core/src/org/jetbrains/kotlin/tools/projectWizard/core/service/EapVersionDownloader.kt +++ b/plugins/kotlin/project-wizard/core/src/org/jetbrains/kotlin/tools/projectWizard/core/service/EapVersionDownloader.kt @@ -1,8 +1,6 @@ // Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.kotlin.tools.projectWizard.core.service -import com.google.gson.JsonObject -import com.google.gson.JsonParser import org.jetbrains.annotations.NonNls import org.jetbrains.kotlin.tools.projectWizard.core.TaskResult import org.jetbrains.kotlin.tools.projectWizard.core.asNullable @@ -15,28 +13,12 @@ import java.net.URL import java.util.stream.Collectors object EapVersionDownloader { - fun getLatestEapVersion() = downloadVersionFromMavenCentral(EAP_URL).firstOrNull() - fun getLatestDevVersion() = downloadVersions(DEV_URL).firstOrNull() + fun getLatestEapVersion() = downloadVersions(EAP_URL).firstOrNull() private fun downloadPage(url: String): TaskResult = safe { BufferedReader(InputStreamReader(URL(url).openStream())).lines().collect(Collectors.joining("\n")) } - @Suppress("SameParameterValue") - private fun downloadVersionFromMavenCentral(url: String) = compute { - val (text) = downloadPage(url) - val (versionString) = parseLatestVersionFromJson(text) - if (versionString.isNotEmpty()) - listOf(Version.fromString(versionString)) - else - emptyList() - }.asNullable.orEmpty() - - private fun parseLatestVersionFromJson(text: String) = safe { - val json = JsonParser.parseString(text) as JsonObject - json.get("response").asJsonObject.get("docs").asJsonArray.get(0).asJsonObject.get("latestVersion").asString - } - @Suppress("SameParameterValue") private fun downloadVersions(url: String): List = compute { val (text) = downloadPage(url) @@ -49,10 +31,7 @@ object EapVersionDownloader { }.asNullable.orEmpty() @NonNls - private val EAP_URL = "https://search.maven.org/solrsearch/select?q=g:org.jetbrains.kotlin%20AND%20a:kotlin-gradle-plugin" - - @NonNls - private val DEV_URL = "https://dl.bintray.com/kotlin/kotlin-dev/org/jetbrains/kotlin/jvm/org.jetbrains.kotlin.jvm.gradle.plugin/" + private val EAP_URL = "https://plugins.gradle.org/m2/org/jetbrains/kotlin/jvm/org.jetbrains.kotlin.jvm.gradle.plugin/" @NonNls private val versionRegexp = """href="([^"\\]+)"""".toRegex() diff --git a/plugins/kotlin/project-wizard/tests/test/org/jetbrains/kotlin/tools/projectWizard/wizard/services/TestWizardServices.kt b/plugins/kotlin/project-wizard/tests/test/org/jetbrains/kotlin/tools/projectWizard/wizard/services/TestWizardServices.kt index dc6d27d2b0fd..a18e2a1e3917 100644 --- a/plugins/kotlin/project-wizard/tests/test/org/jetbrains/kotlin/tools/projectWizard/wizard/services/TestWizardServices.kt +++ b/plugins/kotlin/project-wizard/tests/test/org/jetbrains/kotlin/tools/projectWizard/wizard/services/TestWizardServices.kt @@ -3,7 +3,7 @@ package org.jetbrains.kotlin.tools.projectWizard.wizard.services import com.intellij.openapi.project.Project -import org.jetbrains.kotlin.tools.projectWizard.wizard.service.IdeaKotlinVersionProviderService +import org.jetbrains.kotlin.tools.projectWizard.cli.KotlinVersionProviderTestWizardService import org.jetbrains.kotlin.tools.projectWizard.cli.TestWizardService import org.jetbrains.kotlin.tools.projectWizard.wizard.service.IdeaJvmTargetVersionProviderService @@ -14,7 +14,7 @@ object TestWizardServices { val PROJECT_INDEPENDENT = listOf( FormattingTestWizardService(), - IdeaKotlinVersionProviderService(), + KotlinVersionProviderTestWizardService(), IdeaJvmTargetVersionProviderService() ) } \ No newline at end of file diff --git a/plugins/kotlin/tests-common/test/org/jetbrains/kotlin/idea/asJava/PsiClassRenderer.kt b/plugins/kotlin/tests-common/test/org/jetbrains/kotlin/idea/asJava/PsiClassRenderer.kt index 41d2fb78dc24..2f02ddc8c0d7 100644 --- a/plugins/kotlin/tests-common/test/org/jetbrains/kotlin/idea/asJava/PsiClassRenderer.kt +++ b/plugins/kotlin/tests-common/test/org/jetbrains/kotlin/idea/asJava/PsiClassRenderer.kt @@ -10,6 +10,7 @@ import org.jetbrains.kotlin.asJava.elements.KtLightPsiLiteral import org.jetbrains.kotlin.load.kotlin.NON_EXISTENT_CLASS_NAME import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.resolve.constants.KClassValue fun PsiClass.renderClass() = PsiClassRenderer.renderClass(this) @@ -143,12 +144,19 @@ class PsiClassRenderer private constructor( it.name!! + bounds } + "> " - private fun KtLightPsiLiteral.renderKtLightPsiLiteral(): String = - (value as? Pair<*, *>)?.let { - val classId = it.first as? ClassId - val name = it.second as? Name - if (classId != null && name != null) "${classId.asSingleFqName()}.${name.asString()}" else null - } ?: text + private fun KtLightPsiLiteral.renderKtLightPsiLiteral(): String { + val value = value + if (value is Pair<*, *>) { + val classId = value.first as? ClassId + val name = value.second as? Name + if (classId != null && name != null) + return "${classId.asSingleFqName()}.${name.asString()}" + } + if (value is KClassValue.Value.NormalClass && value.arrayDimensions == 0) { + return "${value.classId.asSingleFqName()}.class" + } + return text + } private fun PsiAnnotationMemberValue.renderAnnotationMemberValue(): String = when (this) { is KtLightPsiArrayInitializerMemberValue -> "{${initializers.joinToString { it.renderAnnotationMemberValue() }}}" diff --git a/plugins/kotlin/uast/uast-kotlin-idea/tests/test/org/jetbrains/uast/test/kotlin/KotlinUastGenerationTest.kt b/plugins/kotlin/uast/uast-kotlin-idea/tests/test/org/jetbrains/uast/test/kotlin/KotlinUastGenerationTest.kt index 2443b053f4c6..ef524c90d89f 100644 --- a/plugins/kotlin/uast/uast-kotlin-idea/tests/test/org/jetbrains/uast/test/kotlin/KotlinUastGenerationTest.kt +++ b/plugins/kotlin/uast/uast-kotlin-idea/tests/test/org/jetbrains/uast/test/kotlin/KotlinUastGenerationTest.kt @@ -519,7 +519,7 @@ class KotlinUastGenerationTest : KotlinLightCodeInsightFixtureTestCase() { """.trimIndent() ) as KtFile - val reference = file.findUElementByTextFromPsi("println(a)") + val reference = file.findUElementByTextFromPsi("println(a)", strict = true) .findElementByTextFromPsi("a") val callExpression = uastElementFactory.createCallExpression(