Skip to content

Commit

Permalink
Adding support for IC-242 (#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
sksamuel authored May 27, 2024
1 parent 9ef5e43 commit 5da5ed7
Show file tree
Hide file tree
Showing 13 changed files with 276 additions and 5 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_single.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
5 changes: 5 additions & 0 deletions src/IC-242/kotlin/io/kotest/plugin/intellij/contentFactory.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package io.kotest.plugin.intellij

import com.intellij.ui.content.ContentFactory

fun getContentFactory(): ContentFactory = ContentFactory.getInstance()
33 changes: 33 additions & 0 deletions src/IC-242/kotlin/io/kotest/plugin/intellij/files.kt
Original file line number Diff line number Diff line change
@@ -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<VirtualFile> {
return FilenameIndex
.getVirtualFilesByName(TagsFilename, false, GlobalSearchScope.allScope(project))
.toList()
}

fun getLocationForFile(
project: Project,
scope: GlobalSearchScope,
name: String,
lineNumber: Int
): PsiLocation<PsiElement>? {
return FilenameIndex
.getVirtualFilesByName(name, scope)
.firstOrNull { it.isTestFile(project) }
?.toPsiFile(project)
?.elementAtLine(lineNumber)
?.toPsiLocation()
}
6 changes: 6 additions & 0 deletions src/IC-242/kotlin/io/kotest/plugin/intellij/findeditor.kt
Original file line number Diff line number Diff line change
@@ -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()
7 changes: 7 additions & 0 deletions src/IC-242/kotlin/io/kotest/plugin/intellij/fqnames.kt
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package io.kotest.plugin.intellij

import org.jetbrains.kotlin.idea.codeinsight.api.classic.inspections.AbstractKotlinInspection

abstract class AbstractInspection : AbstractKotlinInspection()
18 changes: 18 additions & 0 deletions src/IC-242/kotlin/io/kotest/plugin/intellij/markers.kt
Original file line number Diff line number Diff line change
@@ -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<PsiElement>(
element, element.textRange, icon, Functions.constant(text), null, GutterIconRenderer.Alignment.LEFT, { text }
) {
override fun getEditorFilter(): MarkupEditorFilter = MarkupEditorFilterFactory.createIsNotDiffFilter()
}
Original file line number Diff line number Diff line change
@@ -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<out PsiElement> {
return KtClassOrObject::class.java
}

override fun getChildren(parent: PsiElement): Array<StructureViewTreeElement> {
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<TreeElement> {
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
}
}
113 changes: 113 additions & 0 deletions src/IC-242/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<idea-plugin>

<id>kotest-plugin-intellij</id>
<name>Kotest</name>

<vendor email="[email protected]" url="http://github.com/kotest">Kotest</vendor>

<description><![CDATA[
Official IntelliJ-based IDEA plugin for <a href="https://github.com/kotest/kotest">Kotest</a>.<br/><br/>
This plugin requires the use of Kotest 4.2.0 or newer.
]]></description>

<!-- correct values will be set by the build plugin -->
<version>1.0.0</version>
<idea-version since-build="211.6085.26"/>

<depends>org.jetbrains.kotlin</depends>
<depends>com.intellij.modules.java</depends>
<depends>org.jetbrains.plugins.gradle</depends>
<depends optional="true" config-file="intellilang-kotlin-support.xml">org.intellij.intelliLang</depends>

<actions>
<action id="io.kotest.actions.NextTestAction"
class="io.kotest.plugin.intellij.actions.NextTestAction" text="Next Test"
description="Navigate to the next test in this spec class">
<add-to-group group-id="CodeMenu" anchor="last"/>
<keyboard-shortcut keymap="$default" first-keystroke="alt n"/>
</action>

<action id="io.kotest.actions.PreviousTestAction"
class="io.kotest.plugin.intellij.actions.PreviousTestAction" text="Previous Test"
description="Navigate to the previous test in this spec class">
<add-to-group group-id="CodeMenu" anchor="last"/>
<keyboard-shortcut keymap="$default" first-keystroke="alt P"/>
</action>
</actions>

<extensions defaultExtensionNs="com.intellij">
<configurationType implementation="io.kotest.plugin.intellij.KotestConfigurationType"/>

<annotator language="kotlin"
implementationClass="io.kotest.plugin.intellij.annotators.DuplicatedTestNameAnnotator"/>

<annotator language="kotlin"
implementationClass="io.kotest.plugin.intellij.annotators.FocusInNestedTestAnnotator"/>

<!-- <localInspection groupPath="Kotlin" language="JVM" shortName="ShouldBeInstanceOfInspection"-->
<!-- bundle="KotestGadgetsBundle"-->
<!-- key="kotest.should.be.instance.of"-->
<!-- groupBundle="KotestGadgetsBundle" groupKey="group.names.kotest"-->
<!-- enabledByDefault="true" level="WARNING"-->
<!-- implementationClass="io.kotest.plugin.intellij.inspections.ShouldBeInstanceOfInspection"/>-->

<toolWindow id="Kotest" anchor="left" icon="/icon13_greyscale.png"
factoryClass="io.kotest.plugin.intellij.toolwindow.TestExplorerToolWindowFactory"/>

<lang.structureViewExtension implementation="io.kotest.plugin.intellij.structure.KotestStructureViewExtension"/>

<codeInsight.lineMarkerProvider language="kotlin" implementationClass="io.kotest.plugin.intellij.linemarker.InterpolatedTestLineMarker"/>
<codeInsight.lineMarkerProvider language="kotlin" implementationClass="io.kotest.plugin.intellij.linemarker.DisabledTestLineMarker"/>
<runLineMarkerContributor language="kotlin" implementationClass="io.kotest.plugin.intellij.run.TestRunLineMarkerContributor"/>
<runLineMarkerContributor language="kotlin" implementationClass="io.kotest.plugin.intellij.run.SpecRunLineMarkerContributor"/>

<runConfigurationProducer implementation="io.kotest.plugin.intellij.run.SpecRunConfigurationProducer"/>
<runConfigurationProducer implementation="io.kotest.plugin.intellij.run.TestPathRunConfigurationProducer"/>
<runConfigurationProducer implementation="io.kotest.plugin.intellij.run.PackageRunConfigurationProducer"/>
<runConfigurationProducer implementation="io.kotest.plugin.intellij.run.GradleSpecRunConfigurationProducer"/>

<implicitUsageProvider implementation="io.kotest.plugin.intellij.implicits.SpecImplicitUsageProvider"/>
<implicitUsageProvider implementation="io.kotest.plugin.intellij.implicits.ProjectConfigImplicitUsageProvider"/>
<implicitUsageProvider implementation="io.kotest.plugin.intellij.implicits.AutoScanUsageProvider"/>

<testFinder implementation="io.kotest.plugin.intellij.KotestTestFinder"/>
<testFramework id="Kotest" implementation="io.kotest.plugin.intellij.KotestTestFramework"/>
<testGenerator language="kotlin" implementationClass="io.kotest.plugin.intellij.KotestTestGenerator"/>

<codeInsight.externalLibraryResolver implementation="io.kotest.plugin.intellij.KotestExternalLibraryResolver"/>
<stacktrace.fold substring="at io.kotest."/>
<programRunner implementation="io.kotest.plugin.intellij.run.KotestDebuggerRunner"/>
<library.dependencyScopeSuggester implementation="io.kotest.plugin.intellij.KotestDependencyScopeSuggester"/>

<intentionAction>
<className>io.kotest.plugin.intellij.intentions.SoftAssertIntention</className>
<category>Kotlin/Test</category>
<descriptionDirectoryName>SoftAssertIntention</descriptionDirectoryName>
</intentionAction>

<intentionAction>
<className>io.kotest.plugin.intellij.intentions.BangIntention</className>
<category>Kotlin/Test</category>
<descriptionDirectoryName>BangIntention</descriptionDirectoryName>
</intentionAction>

<intentionAction>
<className>io.kotest.plugin.intellij.intentions.ShouldThrowIntention</className>
<category>Kotlin/Test</category>
<descriptionDirectoryName>ShouldThrowIntention</descriptionDirectoryName>
</intentionAction>

<intentionAction>
<className>io.kotest.plugin.intellij.intentions.ShouldThrowAnyIntention</className>
<category>Kotlin/Test</category>
<descriptionDirectoryName>ShouldThrowAnyIntention</descriptionDirectoryName>
</intentionAction>

<intentionAction>
<className>io.kotest.plugin.intellij.intentions.ShouldThrowExactlyIntention</className>
<category>Kotlin/Test</category>
<descriptionDirectoryName>ShouldThrowExactlyIntention</descriptionDirectoryName>
</intentionAction>
</extensions>

</idea-plugin>

0 comments on commit 5da5ed7

Please sign in to comment.