Skip to content

Commit a84b767

Browse files
authored
K2 plugin migration (#321)
1 parent 123d6d9 commit a84b767

File tree

20 files changed

+328
-166
lines changed

20 files changed

+328
-166
lines changed

.github/workflows/master.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ jobs:
1414

1515
strategy:
1616
matrix:
17-
product: [ "IC-223", "IC-231", "IC-232", "IC-233", "IC-241", "IC-242", "IC-243" ]
17+
product: [ "IC-231", "IC-232", "IC-233", "IC-241", "IC-242", "IC-243" ]
1818
include:
19-
- product: "IC-223"
20-
java: "17"
21-
distribution: "temurin"
2219
- product: "IC-231"
2320
java: "17"
2421
distribution: "temurin"

.github/workflows/pr.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
product: [ "IC-223", "IC-231", "IC-232", "IC-233", "IC-241", "IC-242", "IC-243" ]
15+
product: [ "IC-231", "IC-232", "IC-233", "IC-241", "IC-242", "IC-243" ]
1616
include:
17-
- product: "IC-223"
18-
java: "17"
19-
distribution: "temurin"
2017
- product: "IC-231"
2118
java: "17"
2219
distribution: "temurin"

.github/workflows/release.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@ jobs:
88

99
strategy:
1010
matrix:
11-
product: [ "IC-223", "IC-231", "IC-232", "IC-233", "IC-241", "IC-242", "IC-243" ]
11+
product: [ "IC-231", "IC-232", "IC-233", "IC-241", "IC-242", "IC-243" ]
1212
include:
13-
- product: "IC-223"
14-
java: "17"
15-
distribution: "temurin"
1613
- product: "IC-231"
1714
java: "17"
1815
distribution: "temurin"

build.gradle.kts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,6 @@ data class PluginDescriptor(
4545
// and 'until' we can use a wildcard eg 213.*
4646

4747
val descriptors = listOf(
48-
PluginDescriptor(
49-
since = "223.4884.69", // this version is 2022.3
50-
until = "223.*",
51-
sdkVersion = "2022.3",
52-
sourceFolder = "IC-223",
53-
useInstaller = true,
54-
),
5548
PluginDescriptor(
5649
since = "231.8109.163", // this version is 2023.1 release
5750
until = "231.*",
@@ -83,7 +76,7 @@ val descriptors = listOf(
8376
PluginDescriptor(
8477
since = "242.*", // this version is 2024.2.x
8578
until = "243.*",
86-
sdkVersion = "2024.2",
79+
sdkVersion = "2024.2.2",
8780
sourceFolder = "IC-242",
8881
useInstaller = true,
8982
),
@@ -111,6 +104,12 @@ val runWithCustomSandbox by intellijPlatformTesting.runIde.registering {
111104
}
112105
}
113106

107+
val runWithK2Mode by intellijPlatformTesting.runIde.registering {
108+
task {
109+
jvmArgs = listOf("-Didea.kotlin.plugin.use.k2=true")
110+
}
111+
}
112+
114113
intellijPlatform {
115114
buildSearchableOptions = false
116115
projectName = project.name
@@ -165,7 +164,7 @@ dependencies {
165164
// testRuntimeOnly("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1")
166165
}
167166

168-
configurations.all {
167+
configurations.runtimeOnly {
169168
exclude(group = "org.jetbrains.kotlinx", module = "kotlinx-coroutines-core-jvm")
170169
exclude(group = "org.jetbrains.kotlinx", module = "kotlinx-coroutines-core")
171170
exclude(group = "org.jetbrains.kotlinx", module = "kotlinx-coroutines-jdk8")

gradle.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ version=1.1.0
66

77
org.gradle.caching=true
88
sandbox = /tmp/
9+
10+
kotlin.stdlib.default.dependency = false

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
kotlin = "1.9.25"
2+
kotlin = "2.0.21"
33
runtime-kotest = "4.2.0"
44
# We separate these from the actual runtime dependencies
55
test-kotest = "5.9.1"

src/IC-223/kotlin/io/kotest/plugin/intellij/files.kt

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package io.kotest.plugin.intellij.psi
2+
3+
import org.jetbrains.kotlin.idea.caches.resolve.analyze
4+
import org.jetbrains.kotlin.name.FqName
5+
import org.jetbrains.kotlin.psi.KtClassOrObject
6+
import org.jetbrains.kotlin.resolve.BindingContext
7+
import org.jetbrains.kotlin.resolve.descriptorUtil.classId
8+
import org.jetbrains.kotlin.types.typeUtil.supertypes
9+
10+
/**
11+
* Recursively returns the list of classes and interfaces extended or implemented by the class.
12+
*/
13+
fun KtClassOrObject.getAllSuperClasses(): List<FqName> {
14+
return superTypeListEntries
15+
.mapNotNull { it.typeReference }
16+
.mapNotNull {
17+
runCatching {
18+
val bindingContext = it.analyze()
19+
bindingContext.get(BindingContext.TYPE, it)
20+
}.getOrNull()
21+
}.flatMap {
22+
runCatching {
23+
it.supertypes() + it
24+
}.getOrElse { emptyList() }
25+
}.mapNotNull {
26+
runCatching {
27+
it.constructor.declarationDescriptor.classId
28+
}.getOrNull()
29+
}.mapNotNull {
30+
runCatching {
31+
val packageName = it.packageFqName
32+
val simpleName = it.relativeClassName
33+
FqName("$packageName.$simpleName")
34+
}.getOrNull()
35+
}.filterNot { it.toString() == "kotlin.Any" }
36+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package io.kotest.plugin.intellij.psi
2+
3+
import org.jetbrains.kotlin.idea.caches.resolve.analyze
4+
import org.jetbrains.kotlin.name.FqName
5+
import org.jetbrains.kotlin.psi.KtClassOrObject
6+
import org.jetbrains.kotlin.resolve.BindingContext
7+
import org.jetbrains.kotlin.resolve.descriptorUtil.classId
8+
import org.jetbrains.kotlin.types.typeUtil.supertypes
9+
10+
/**
11+
* Recursively returns the list of classes and interfaces extended or implemented by the class.
12+
*/
13+
fun KtClassOrObject.getAllSuperClasses(): List<FqName> {
14+
return superTypeListEntries
15+
.mapNotNull { it.typeReference }
16+
.mapNotNull {
17+
runCatching {
18+
val bindingContext = it.analyze()
19+
bindingContext.get(BindingContext.TYPE, it)
20+
}.getOrNull()
21+
}.flatMap {
22+
runCatching {
23+
it.supertypes() + it
24+
}.getOrElse { emptyList() }
25+
}.mapNotNull {
26+
runCatching {
27+
it.constructor.declarationDescriptor.classId
28+
}.getOrNull()
29+
}.mapNotNull {
30+
runCatching {
31+
val packageName = it.packageFqName
32+
val simpleName = it.relativeClassName
33+
FqName("$packageName.$simpleName")
34+
}.getOrNull()
35+
}.filterNot { it.toString() == "kotlin.Any" }
36+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package io.kotest.plugin.intellij.psi
2+
3+
import org.jetbrains.kotlin.idea.caches.resolve.analyze
4+
import org.jetbrains.kotlin.name.FqName
5+
import org.jetbrains.kotlin.psi.KtClassOrObject
6+
import org.jetbrains.kotlin.resolve.BindingContext
7+
import org.jetbrains.kotlin.resolve.descriptorUtil.classId
8+
import org.jetbrains.kotlin.types.typeUtil.supertypes
9+
10+
/**
11+
* Recursively returns the list of classes and interfaces extended or implemented by the class.
12+
*/
13+
fun KtClassOrObject.getAllSuperClasses(): List<FqName> {
14+
return superTypeListEntries
15+
.mapNotNull { it.typeReference }
16+
.mapNotNull {
17+
runCatching {
18+
val bindingContext = it.analyze()
19+
bindingContext.get(BindingContext.TYPE, it)
20+
}.getOrNull()
21+
}.flatMap {
22+
runCatching {
23+
it.supertypes() + it
24+
}.getOrElse { emptyList() }
25+
}.mapNotNull {
26+
runCatching {
27+
it.constructor.declarationDescriptor.classId
28+
}.getOrNull()
29+
}.mapNotNull {
30+
runCatching {
31+
val packageName = it.packageFqName
32+
val simpleName = it.relativeClassName
33+
FqName("$packageName.$simpleName")
34+
}.getOrNull()
35+
}.filterNot { it.toString() == "kotlin.Any" }
36+
}

0 commit comments

Comments
 (0)