Skip to content

Commit

Permalink
Update to Kotlin 1.8.0 and idea 2022.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Him188 committed Jan 29, 2023
1 parent d521897 commit 8e3b541
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 32 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

plugins {
kotlin("multiplatform") apply false
id("me.him188.maven-central-publish") version "1.0.0-dev-3" apply false
id("me.him188.maven-central-publish") version "1.0.0" apply false
kotlin("kapt") apply false
kotlin("plugin.serialization") version Versions.kotlin apply false
id("com.gradle.plugin-publish") version "0.18.0" apply false
Expand Down
5 changes: 3 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ repositories {

kotlin {
sourceSets.all {
languageSettings.useExperimentalAnnotation("kotlin.Experimental")
languageSettings.useExperimentalAnnotation("kotlin.RequiresOptIn")
languageSettings.optIn("kotlin.Experimental")
languageSettings.optIn("kotlin.RequiresOptIn")
}
}

Expand All @@ -20,6 +20,7 @@ dependencies {

compileOnly(gradleApi())
api("org.jetbrains.kotlin:kotlin-gradle-plugin:${version("kotlin")}")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.2.0")

compileOnly("com.github.jengelman.gradle.plugins:shadow:6.0.0")
}
Expand Down
10 changes: 5 additions & 5 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
@file:Suppress("MemberVisibilityCanBePrivate")

object Versions {
const val intellij = "2022.2.4"
const val intellij = "2022.3"

const val project = "2.2.0-180.1"
const val idePlugin = "222-$project"
const val idePlugin = "223-$project"

const val kotlin = "1.8.0-Beta"
const val kotlinIdea = "222-1.8.0-Beta-release-224-IJ4167.29@eap"
const val coroutines = "1.6.1"
const val kotlin = "1.8.0"
val kotlinIdea: String? = null
const val coroutines = "1.6.4"

const val publicationGroup = "me.him188"
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Wed Mar 04 22:27:09 CST 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down
21 changes: 11 additions & 10 deletions ide-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile

plugins {
id("org.jetbrains.intellij") version "1.7.0"
id("org.jetbrains.intellij") version "1.12.0"
kotlin("jvm")
kotlin("plugin.serialization")

Expand All @@ -13,16 +13,14 @@ kotlin.targets.asSequence()
.filter { it.platformType == org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType.jvm }
.map { it.kotlinOptions }
.filterIsInstance<org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions>()
.forEach { it.jvmTarget = "11" }
.forEach { it.jvmTarget = "17" }

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

dependencies {
compileOnly(kotlin("stdlib-jdk8"))

api(project(":kotlin-jvm-blocking-bridge-runtime"))
api(project(":kotlin-jvm-blocking-bridge-compiler"))

Expand All @@ -47,7 +45,10 @@ intellij {
listOf(
// "org.jetbrains.kotlin:211-1.5.30-M1-release-141-IJ7442.40@eap",
"java",
"org.jetbrains.kotlin:${Versions.kotlinIdea}"
if (Versions.kotlinIdea == null)
"org.jetbrains.kotlin"
else
"org.jetbrains.kotlin:${Versions.kotlinIdea}"
)
)
}
Expand All @@ -63,11 +64,11 @@ tasks.getByName("publishPlugin", org.jetbrains.intellij.tasks.PublishPluginTask:
}

tasks.withType<org.jetbrains.intellij.tasks.PatchPluginXmlTask> {
sinceBuild.set("213.0")
untilBuild.set("222.*")
sinceBuild.set("223.0")
untilBuild.set("223.*")
changeNotes.set(
"""
See <a href="">Release notes</a>
See <a href="https://github.com/Him188/kotlin-jvm-blocking-bridge">Release notes</a>
""".trimIndent()
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import com.intellij.openapi.Disposable
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListenerAdapter
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskType
import com.intellij.openapi.progress.util.BackgroundTaskUtil
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.idea.util.ProgressIndicatorUtils
import com.intellij.openapi.util.Computable
import org.jetbrains.kotlin.idea.util.projectStructure.allModules

class BridgeProjectImportListener : Disposable, ExternalSystemTaskNotificationListenerAdapter() {
Expand All @@ -17,11 +18,11 @@ class BridgeProjectImportListener : Disposable, ExternalSystemTaskNotificationLi
if (id.type == ExternalSystemTaskType.RESOLVE_PROJECT) {
// At this point changes might be still not applied to project structure yet.
val project = id.findResolvedProject() ?: return
ProgressIndicatorUtils.runUnderDisposeAwareIndicator(this) {
BackgroundTaskUtil.runUnderDisposeAwareIndicator(this, Computable {
for (module in project.allModules()) {
module.getServiceIfCreated(BridgeModuleCacheService::class.java)?.initialized = false
}
}
})
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKind
import org.jetbrains.kotlin.utils.addToStdlib.safeAs

/**
* Allows inserting elements into a PsiElement
Expand Down Expand Up @@ -195,7 +194,7 @@ internal fun KtLightMethod.generateLightMethod(
return BlockingBridgeStubMethod(kotlinOrigin, containingClass, originMethod, parameters)
}

val overloads = originMethod.kotlinOrigin.safeAs<KtNamedFunction>()?.valueParameters // last is Continuation
val overloads = (originMethod.kotlinOrigin as? KtNamedFunction)?.valueParameters // last is Continuation
?.jvmOverloads(originMethod.parameterList) ?: return emptyList()

if (overloads.isEmpty()) return emptyList()
Expand Down Expand Up @@ -317,6 +316,7 @@ internal class BlockingBridgeStubMethod(
is PsiWildcardType -> { // ? super String
(type.bound ?: type).coerceUnitToVoid()
}

else -> {
type.coerceUnitToVoid()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package me.him188.kotlin.jvm.blocking.bridge.ide

import com.intellij.openapi.module.Module
import com.intellij.psi.PsiElement
import com.intellij.util.castSafelyTo
import me.him188.kotlin.jvm.blocking.bridge.compiler.extensions.BridgeCommandLineProcessor
import me.him188.kotlin.jvm.blocking.bridge.compiler.extensions.IBridgeConfiguration
import me.him188.kotlin.jvm.blocking.bridge.compiler.extensions.createBridgeConfig
Expand Down Expand Up @@ -59,7 +58,7 @@ inline fun <R> Module.useBridgeCacheOrInit(

fun ModuleDescriptor.isIr(): Boolean {
val compilerArguments = kotlinFacetSettings()?.compilerArguments ?: return true // true by default
if (compilerArguments.castSafelyTo<K2JVMCompilerArguments>()?.useOldBackend == true) {
if ((compilerArguments as? K2JVMCompilerArguments?)?.useOldBackend == true) {
return false
}
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import org.jetbrains.kotlin.idea.util.findAnnotation
import org.jetbrains.kotlin.psi.KtAnnotationEntry
import org.jetbrains.kotlin.psi.KtFunction
import org.jetbrains.kotlin.psi.KtModifierListOwner
import org.jetbrains.kotlin.utils.addToStdlib.safeAs

class RemoveJvmBlockingBridgeFix(
element: KtFunction,
Expand All @@ -29,8 +28,10 @@ class RemoveJvmBlockingBridgeFix(

companion object : KotlinSingleIntentionActionFactory() {
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
val target = diagnostic.psiElement.safeAs<KtAnnotationEntry>()?.parentsOfType<KtFunction>()?.firstOrNull()
?: return null
val target =
(diagnostic.psiElement as? KtAnnotationEntry)?.parentsOfType<KtFunction>()
?.firstOrNull()
?: return null
return RemoveJvmBlockingBridgeFix(target)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import org.jetbrains.kotlin.psi.KtAnnotationEntry
import org.jetbrains.kotlin.psi.KtFunction
import org.jetbrains.kotlin.psi.KtModifierListOwner
import org.jetbrains.kotlin.resolve.jvm.annotations.JVM_SYNTHETIC_ANNOTATION_FQ_NAME
import org.jetbrains.kotlin.utils.addToStdlib.safeAs

class RemoveJvmSyntheticFix(
element: KtFunction,
Expand All @@ -29,8 +28,10 @@ class RemoveJvmSyntheticFix(

companion object : KotlinSingleIntentionActionFactory() {
override fun createAction(diagnostic: Diagnostic): IntentionAction? {
val target = diagnostic.psiElement.safeAs<KtAnnotationEntry>()?.parentsOfType<KtFunction>()?.firstOrNull()
?: return null
val target =
(diagnostic.psiElement as? KtAnnotationEntry)?.parentsOfType<KtFunction>()
?.firstOrNull()
?: return null
return RemoveJvmSyntheticFix(target)
}

Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pluginManagement {
repositories {
gradlePluginPortal()
maven("https://oss.sonatype.org/content/repositories/snapshots/")
mavenLocal()
}
}
Expand Down

0 comments on commit 8e3b541

Please sign in to comment.