Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 5 additions & 21 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,10 @@ data class PluginDescriptor(

val descriptors = listOf(
PluginDescriptor(
since = "242.*", // this version is 2024.2.x
until = "243.*",
sdkVersion = "2024.2.2",
sourceFolder = "IC-242",
useInstaller = true,
jdkTarget = JavaVersion.VERSION_17,
),
PluginDescriptor(
since = "243.*", // this version is 2024.3.x
until = "251.*",
sdkVersion = "2024.3.1",
sourceFolder = "IC-243",
useInstaller = true,
jdkTarget = JavaVersion.VERSION_17,
),
PluginDescriptor(
since = "251.*", // this version is 2025.1.x
until = "252.*",
sdkVersion = "2025.1",
sourceFolder = "IC-251",
since = "252.*", // this version is 2025.2.x
until = "261.*",
sdkVersion = "2025.2",
sourceFolder = "IC-252",
useInstaller = true,
jdkTarget = JavaVersion.VERSION_21,
),
Expand All @@ -65,7 +49,7 @@ val descriptors = listOf(
),
)

val productName = System.getenv("PRODUCT_NAME") ?: "IC-251"
val productName = System.getenv("PRODUCT_NAME") ?: "IC-252"
val descriptor: PluginDescriptor = descriptors.first { it.sourceFolder == productName }
val jvmTargetVersion: String = System.getenv("JVM_TARGET") ?: descriptor.jdkTarget.majorVersion

Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[versions]
kotlin = "2.2.0"
runtime-kotest = "4.2.0"
# We separate these from the actual runtime dependencies
test-kotest = "5.9.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import com.intellij.psi.PsiFile
import com.intellij.psi.impl.source.PostprocessReformattingAspect
import com.intellij.refactoring.util.classMembers.MemberInfo
import com.intellij.testIntegration.createTest.CreateTestDialog
import com.intellij.testIntegration.createTest.JavaTestGenerator
import com.intellij.testIntegration.createTest.TestGenerator
import com.intellij.util.concurrency.annotations.RequiresReadLock
import io.kotest.plugin.intellij.Constants
import io.kotest.plugin.intellij.KotestTestFramework
Expand All @@ -27,32 +27,28 @@ import org.jetbrains.kotlin.idea.KotlinLanguage
import org.jetbrains.kotlin.idea.refactoring.memberInfo.toKotlinMemberInfo
import org.jetbrains.kotlin.name.FqName
import java.util.Properties

/**
* Used to create "Template" test class files.
*/
class KotestTestGenerator : JavaTestGenerator() {
class KotestTestGenerator : TestGenerator {

override fun toString(): String = KotlinLanguage.INSTANCE.displayName

override fun generateTest(project: Project, d: CreateTestDialog): PsiElement? {
// I do not currently know how to limit the test generator to only kotest, therefore we can check
// the framework name and delegate to the JavaTestGenerator one. But this only works while JavaTestGenerator
// is public, and has a zero arg constructor, so I would like to find a better long term solution:
// https://intellij-support.jetbrains.com/hc/en-us/community/posts/15040678418450-How-to-choose-when-to-apply-TestGenerator
if (d.selectedTestFrameworkDescriptor.name != Constants.FRAMEWORK_NAME)
return super.generateTest(project, d)
return PostprocessReformattingAspect.getInstance(project).postponeFormattingInside(Computable {
ApplicationManager.getApplication().runWriteAction(Computable<PsiElement?> {
val file = generateTestFile(project, d)
if (file != null) {
// without this the file is created but the caret stays in the original file
CodeInsightUtil.positionCursor(project, file, file)
}
file
override fun generateTest(project: Project, d: CreateTestDialog): PsiElement? =
if (d.selectedTestFrameworkDescriptor.name == Constants.FRAMEWORK_NAME) {
PostprocessReformattingAspect.getInstance(project).postponeFormattingInside(Computable {
ApplicationManager.getApplication().runWriteAction(Computable<PsiElement?> {
val file = generateTestFile(project, d)
if (file != null) {
// without this the file is created but the caret stays in the original file
CodeInsightUtil.positionCursor(project, file, file)
}
file
})
})
})
}
} else {
null
}

private fun styleForSuperClass(fqn: FqName): SpecStyle =
SpecStyle.Companion.styles.find { it.fqn() == fqn } ?: FunSpecStyle
Expand Down