diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1fe5a4a4..40949ff6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: - product: [ "IC-211", "IC-212", "IC-213", "IC-221", "IC-222", "IC-223", "IC-231", "IC-232", "IC-233", "IC-241" ] + product: [ "IC-211", "IC-212", "IC-213", "IC-221", "IC-222", "IC-223", "IC-231", "IC-232", "IC-233", "IC-241", "IC-242" ] include: - product: "IC-211" java: "11" @@ -46,6 +46,9 @@ jobs: - product: "IC-241" java: "17" distribution: "temurin" + - product: "IC-242" + java: "17" + distribution: "temurin" max-parallel: 10 fail-fast: false diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 0044f0db..427a0e5a 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: - product: [ "IC-211", "IC-212", "IC-213", "IC-221", "IC-222", "IC-223", "IC-231", "IC-232", "IC-233", "IC-241" ] + product: [ "IC-211", "IC-212", "IC-213", "IC-221", "IC-222", "IC-223", "IC-231", "IC-232", "IC-233", "IC-241", "IC-242" ] include: - product: "IC-211" java: "11" @@ -44,6 +44,9 @@ jobs: - product: "IC-241" java: "17" distribution: "temurin" + - product: "IC-242" + java: "17" + distribution: "temurin" max-parallel: 10 fail-fast: false diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8ff1d508..b2d763f8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: - product: [ "IC-211", "IC-212", "IC-213", "IC-221", "IC-222", "IC-223", "IC-231", "IC-232", "IC-233", "IC-241" ] + product: [ "IC-211", "IC-212", "IC-213", "IC-221", "IC-222", "IC-223", "IC-231", "IC-232", "IC-233", "IC-241", "IC-242" ] include: - product: "IC-211" java: "11" @@ -40,6 +40,9 @@ jobs: - product: "IC-241" java: "17" distribution: "temurin" + - product: "IC-242" + java: "17" + distribution: "temurin" max-parallel: 1 runs-on: ubuntu-latest diff --git a/.github/workflows/release_single.yml b/.github/workflows/release_single.yml index 1f65d13d..13f997eb 100644 --- a/.github/workflows/release_single.yml +++ b/.github/workflows/release_single.yml @@ -5,7 +5,7 @@ on: inputs: sdk: type: string - description: "sdk folder eg IC-222" + description: "sdk folder eg IC-242" required: true java: type: string diff --git a/build.gradle.kts b/build.gradle.kts index 1126da1b..256813b5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -115,9 +115,16 @@ val plugins = listOf( sourceFolder = "IC-241", deps = listOf("java", "org.jetbrains.plugins.gradle", "org.jetbrains.kotlin") ), + PluginDescriptor( + since = "241.17011.108", // this version is 2024.2 + until = "242.*", + sdkVersion = "241.17011-EAP-CANDIDATE-SNAPSHOT", + sourceFolder = "IC-242", + deps = listOf("java", "org.jetbrains.plugins.gradle", "org.jetbrains.kotlin") + ), ) -val productName = System.getenv("PRODUCT_NAME") ?: "IC-241" +val productName = System.getenv("PRODUCT_NAME") ?: "IC-242" val jvmTarget = System.getenv("JVM_TARGET") ?: "11" val descriptor = plugins.first { it.sourceFolder == productName } diff --git a/src/IC-242/kotlin/io/kotest/plugin/intellij/contentFactory.kt b/src/IC-242/kotlin/io/kotest/plugin/intellij/contentFactory.kt new file mode 100644 index 00000000..3cd76f88 --- /dev/null +++ b/src/IC-242/kotlin/io/kotest/plugin/intellij/contentFactory.kt @@ -0,0 +1,5 @@ +package io.kotest.plugin.intellij + +import com.intellij.ui.content.ContentFactory + +fun getContentFactory(): ContentFactory = ContentFactory.getInstance() diff --git a/src/IC-242/kotlin/io/kotest/plugin/intellij/files.kt b/src/IC-242/kotlin/io/kotest/plugin/intellij/files.kt new file mode 100644 index 00000000..3f047009 --- /dev/null +++ b/src/IC-242/kotlin/io/kotest/plugin/intellij/files.kt @@ -0,0 +1,33 @@ +package io.kotest.plugin.intellij + +import com.intellij.execution.PsiLocation +import com.intellij.openapi.project.Project +import com.intellij.openapi.vfs.VirtualFile +import com.intellij.psi.PsiElement +import com.intellij.psi.search.FilenameIndex +import com.intellij.psi.search.GlobalSearchScope +import io.kotest.plugin.intellij.psi.elementAtLine +import io.kotest.plugin.intellij.psi.isTestFile +import io.kotest.plugin.intellij.psi.toPsiLocation +import io.kotest.plugin.intellij.toolwindow.TagsFilename +import org.jetbrains.kotlin.idea.core.util.toPsiFile + +fun findFiles(project: Project): List { + return FilenameIndex + .getVirtualFilesByName(TagsFilename, false, GlobalSearchScope.allScope(project)) + .toList() +} + +fun getLocationForFile( + project: Project, + scope: GlobalSearchScope, + name: String, + lineNumber: Int +): PsiLocation? { + return FilenameIndex + .getVirtualFilesByName(name, scope) + .firstOrNull { it.isTestFile(project) } + ?.toPsiFile(project) + ?.elementAtLine(lineNumber) + ?.toPsiLocation() +} diff --git a/src/IC-242/kotlin/io/kotest/plugin/intellij/findeditor.kt b/src/IC-242/kotlin/io/kotest/plugin/intellij/findeditor.kt new file mode 100644 index 00000000..aeb4fca5 --- /dev/null +++ b/src/IC-242/kotlin/io/kotest/plugin/intellij/findeditor.kt @@ -0,0 +1,6 @@ +package io.kotest.plugin.intellij + +import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.idea.codeinsight.utils.findExistingEditor + +fun PsiElement.existingEditor() = this.findExistingEditor() diff --git a/src/IC-242/kotlin/io/kotest/plugin/intellij/fqnames.kt b/src/IC-242/kotlin/io/kotest/plugin/intellij/fqnames.kt new file mode 100644 index 00000000..5318e346 --- /dev/null +++ b/src/IC-242/kotlin/io/kotest/plugin/intellij/fqnames.kt @@ -0,0 +1,7 @@ +package io.kotest.plugin.intellij + +import org.jetbrains.kotlin.idea.base.psi.kotlinFqName +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.psi.KtClassOrObject + +fun KtClassOrObject.fqname(): FqName? = this.kotlinFqName diff --git a/src/IC-242/kotlin/io/kotest/plugin/intellij/inspectionsuper.kt b/src/IC-242/kotlin/io/kotest/plugin/intellij/inspectionsuper.kt new file mode 100644 index 00000000..9ea4f784 --- /dev/null +++ b/src/IC-242/kotlin/io/kotest/plugin/intellij/inspectionsuper.kt @@ -0,0 +1,5 @@ +package io.kotest.plugin.intellij + +import org.jetbrains.kotlin.idea.codeinsight.api.classic.inspections.AbstractKotlinInspection + +abstract class AbstractInspection : AbstractKotlinInspection() diff --git a/src/IC-242/kotlin/io/kotest/plugin/intellij/markers.kt b/src/IC-242/kotlin/io/kotest/plugin/intellij/markers.kt new file mode 100644 index 00000000..6bd63cde --- /dev/null +++ b/src/IC-242/kotlin/io/kotest/plugin/intellij/markers.kt @@ -0,0 +1,18 @@ +package io.kotest.plugin.intellij + +import com.intellij.codeInsight.daemon.LineMarkerInfo +import com.intellij.openapi.editor.markup.GutterIconRenderer +import com.intellij.openapi.editor.markup.MarkupEditorFilter +import com.intellij.openapi.editor.markup.MarkupEditorFilterFactory +import com.intellij.psi.PsiElement +import com.intellij.util.Functions +import javax.swing.Icon + +/** + * A Line marker that does not appear in diffs + */ +class MainEditorLineMarkerInfo(element: PsiElement, text: String, icon: Icon) : LineMarkerInfo( + element, element.textRange, icon, Functions.constant(text), null, GutterIconRenderer.Alignment.LEFT, { text } +) { + override fun getEditorFilter(): MarkupEditorFilter = MarkupEditorFilterFactory.createIsNotDiffFilter() +} diff --git a/src/IC-242/kotlin/io/kotest/plugin/intellij/structure/KotestStructureViewExtension.kt b/src/IC-242/kotlin/io/kotest/plugin/intellij/structure/KotestStructureViewExtension.kt new file mode 100644 index 00000000..8aa0e602 --- /dev/null +++ b/src/IC-242/kotlin/io/kotest/plugin/intellij/structure/KotestStructureViewExtension.kt @@ -0,0 +1,68 @@ +package io.kotest.plugin.intellij.structure + +import com.intellij.icons.AllIcons +import com.intellij.ide.structureView.StructureViewExtension +import com.intellij.ide.structureView.StructureViewTreeElement +import com.intellij.ide.util.treeView.smartTree.TreeElement +import com.intellij.navigation.ItemPresentation +import com.intellij.openapi.editor.Editor +import com.intellij.psi.NavigatablePsiElement +import com.intellij.psi.PsiElement +import io.kotest.plugin.intellij.TestElement +import io.kotest.plugin.intellij.psi.specStyle +import org.jetbrains.kotlin.psi.KtClassOrObject +import javax.swing.Icon + +class KotestStructureViewExtension : StructureViewExtension { + + override fun getType(): Class { + return KtClassOrObject::class.java + } + + override fun getChildren(parent: PsiElement): Array { + val ktClassOrObject = parent as? KtClassOrObject ?: return emptyArray() + val spec = ktClassOrObject.specStyle() ?: return emptyArray() + val tests = spec.tests(parent, false) + return tests.map { KotestTestStructureViewTreeElement(it) }.toTypedArray() + } + + class KotestTestStructureViewTreeElement(private val test: TestElement) : StructureViewTreeElement { + override fun getPresentation(): ItemPresentation { + return object : ItemPresentation { + override fun getIcon(unused: Boolean): Icon { + return AllIcons.Nodes.Test + } + + override fun getPresentableText(): String { + return test.test.name.displayName() + } + } + } + + override fun getChildren(): Array { + return test.nestedTests.map { KotestTestStructureViewTreeElement(it) }.toTypedArray() + } + + override fun navigate(requestFocus: Boolean) { + if (test.psi is NavigatablePsiElement) { + test.psi.navigate(true) + } + } + + override fun canNavigate(): Boolean { + return true + } + + override fun canNavigateToSource(): Boolean { + return true + } + + override fun getValue(): Any { + return test + } + } + + override fun getCurrentEditorElement(editor: Editor?, parent: PsiElement?): Any? { + return null + } +} diff --git a/src/IC-242/resources/META-INF/plugin.xml b/src/IC-242/resources/META-INF/plugin.xml new file mode 100644 index 00000000..ef2d22a2 --- /dev/null +++ b/src/IC-242/resources/META-INF/plugin.xml @@ -0,0 +1,113 @@ + + + kotest-plugin-intellij + Kotest + + Kotest + + Kotest.

+ This plugin requires the use of Kotest 4.2.0 or newer. + ]]>
+ + + 1.0.0 + + + org.jetbrains.kotlin + com.intellij.modules.java + org.jetbrains.plugins.gradle + org.intellij.intelliLang + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + io.kotest.plugin.intellij.intentions.SoftAssertIntention + Kotlin/Test + SoftAssertIntention + + + + io.kotest.plugin.intellij.intentions.BangIntention + Kotlin/Test + BangIntention + + + + io.kotest.plugin.intellij.intentions.ShouldThrowIntention + Kotlin/Test + ShouldThrowIntention + + + + io.kotest.plugin.intellij.intentions.ShouldThrowAnyIntention + Kotlin/Test + ShouldThrowAnyIntention + + + + io.kotest.plugin.intellij.intentions.ShouldThrowExactlyIntention + Kotlin/Test + ShouldThrowExactlyIntention + + + +