Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
akozlova authored Oct 1, 2024
2 parents 17f4a8b + e741607 commit 19cff14
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 61 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

strategy:
matrix:
product: [ "IC-223", "IC-231", "IC-232", "IC-233", "IC-241", "IC-242" ]
product: [ "IC-223", "IC-231", "IC-232", "IC-233", "IC-241", "IC-242", "IC-243" ]
include:
- product: "IC-223"
java: "17"
Expand All @@ -34,6 +34,9 @@ jobs:
- product: "IC-242"
java: "17"
distribution: "temurin"
- product: "IC-243"
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-223", "IC-231", "IC-232", "IC-233", "IC-241", "IC-242" ]
product: [ "IC-223", "IC-231", "IC-232", "IC-233", "IC-241", "IC-242", "IC-243" ]
include:
- product: "IC-223"
java: "17"
Expand All @@ -32,6 +32,9 @@ jobs:
- product: "IC-242"
java: "17"
distribution: "temurin"
- product: "IC-243"
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-223", "IC-231", "IC-232", "IC-233", "IC-241", "IC-242" ]
product: [ "IC-223", "IC-231", "IC-232", "IC-233", "IC-241", "IC-242", "IC-243" ]
include:
- product: "IC-223"
java: "17"
Expand All @@ -28,6 +28,9 @@ jobs:
- product: "IC-242"
java: "17"
distribution: "temurin"
- product: "IC-243"
java: "17"
distribution: "temurin"
max-parallel: 1

runs-on: ubuntu-latest
Expand Down
40 changes: 36 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
import org.jetbrains.intellij.platform.gradle.models.ProductRelease

plugins {
id("java")
Expand All @@ -12,6 +14,7 @@ repositories {
maven("https://oss.sonatype.org/content/repositories/snapshots")
intellijPlatform {
defaultRepositories()
jetbrainsRuntime()
}
}

Expand All @@ -22,6 +25,7 @@ data class PluginDescriptor(
// https://github.com/JetBrains/gradle-intellij-plugin#intellij-platform-properties
val sdkVersion: String, // the version string passed to the intellij sdk gradle plugin
val sourceFolder: String, // used as the source root for specifics of this build
val useInstaller: Boolean, // required to be false for EAP builds
)

// https://jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html
Expand All @@ -46,40 +50,53 @@ val descriptors = listOf(
until = "223.*",
sdkVersion = "2022.3",
sourceFolder = "IC-223",
useInstaller = true,
),
PluginDescriptor(
since = "231.8109.163", // this version is 2023.1 release
until = "231.*",
sdkVersion = "2023.1",
sourceFolder = "IC-231",
useInstaller = true,
),
PluginDescriptor(
since = "232.5150.116", // this version is 2023.2
until = "232.*",
sdkVersion = "2023.2",
sourceFolder = "IC-232",
useInstaller = true,
),
PluginDescriptor(
since = "233.9802.16", // this version is 2023.3
until = "233.*",
sdkVersion = "2023.3",
sourceFolder = "IC-233",
useInstaller = true,
),
PluginDescriptor(
since = "241.15989.150", // this version is 2024.1.x
until = "242.*",
sdkVersion = "2024.1",
sourceFolder = "IC-241",
useInstaller = true,
),
PluginDescriptor(
since = "242.*", // this version is 2024.2.x
until = "243.*",
sdkVersion = "2024.2.2",
sourceFolder = "IC-242",
useInstaller = true,
),
PluginDescriptor(
since = "243.*", // this version is 2024.3.x
until = "244.*",
sdkVersion = "243-EAP-SNAPSHOT",
sourceFolder = "IC-243",
useInstaller = false,
),
)

val productName = System.getenv("PRODUCT_NAME") ?: "IC-242"
val productName = System.getenv("PRODUCT_NAME") ?: "IC-243"
val jvmTargetVersion = System.getenv("JVM_TARGET") ?: "11"
val descriptor = descriptors.first { it.sourceFolder == productName }

Expand Down Expand Up @@ -110,11 +127,10 @@ intellijPlatform {
buildSearchableOptions = false
projectName = project.name
instrumentCode = true

pluginConfiguration {
name = "kotest-plugin-intellij"
id = "kotest-plugin-intellij"
description = "Official Kotest plugin for IntelliJ IDEA fo running tests in the IDE"
description = "Official Kotest plugin for IntelliJ IDEA for running tests in the IDE"
version = project.version.toString() + "-" + descriptor.sdkVersion
vendor {
name = "Kotest"
Expand All @@ -132,7 +148,10 @@ intellijPlatform {
dependencies {
testImplementation("junit:junit:4.13.2")
intellijPlatform {
intellijIdeaCommunity(descriptor.sdkVersion)
// snapshots here https://www.jetbrains.com/intellij-repository/snapshots/
intellijIdeaCommunity(descriptor.sdkVersion, useInstaller = descriptor.useInstaller)
if (!descriptor.useInstaller)
jetbrainsRuntime()
instrumentationTools()
pluginVerifier()
zipSigner()
Expand Down Expand Up @@ -191,3 +210,16 @@ tasks {
include("**/*Tests.class")
}
}

tasks {
printProductsReleases {
channels = listOf(ProductRelease.Channel.EAP)
types = listOf(IntelliJPlatformType.IntellijIdeaCommunity)
untilBuild = provider { null }

doLast {
val latestEap = productsReleases.get().max()
println("Latest EAP build: $latestEap")
}
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
30 changes: 30 additions & 0 deletions src/IC-243/kotlin/io/kotest/plugin/intellij/files.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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>? {
val testFile = FilenameIndex.getVirtualFilesByName(name, scope).firstOrNull { it.isTestFile(project) } ?: return null
// element at line is 1 indexed, so we need to add one
return testFile.toPsiFile(project)?.elementAtLine(lineNumber + 1)?.toPsiLocation()
}
4 changes: 2 additions & 2 deletions src/main/kotlin/io/kotest/plugin/intellij/KotestTestFinder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class KotestTestFinder : TestFinder {
}

/**
* This is used by the navivation menu to determine if it should show "navigate to tests" or
* "nagivate to test subjects". Depending on the response, [findClassesForTest] or
* This is used by the navigation menu to determine if it should show "navigate to tests" or
* "navigate to test subjects". Depending on the response, [findClassesForTest] or
* [findTestsForClass] will be called.
*/
override fun isTest(element: PsiElement): Boolean = element.isContainedInSpec()
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/io/kotest/plugin/intellij/psi/offsets.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.intellij.execution.PsiLocation
import com.intellij.psi.PsiDocumentManager
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
import com.intellij.psi.util.PsiUtilCore

/**
* Returns the offsets for the given line in this file, or -1 if the document cannot be loaded for this file.
Expand All @@ -21,14 +22,13 @@ fun PsiFile.offsetForLine(line: Int): IntRange? {

/**
* Finds the first [PsiElement] for the given offset range by iterating over
* the values in the range until an element is found.
* the values in the range until an element that is not a whitespace is found.
*/
fun PsiElement.findElementInRange(offsets: IntRange): PsiElement? {
return offsets.asSequence()
.mapNotNull { findElementAt(it) }
.mapNotNull { offset -> findElementAt(offset)?.takeIf { it.text?.isNotBlank() == true } }
.firstOrNull()
}

/**
* Returns the first element for the given line in this file,
* or null if the document cannot be loaded for this file.
Expand Down
6 changes: 3 additions & 3 deletions src/test/kotlin/io/kotest/plugin/intellij/psi/OffsetsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class OffsetsTest : LightJavaCodeInsightFixtureTestCase() {
val psiFile = myFixture.configureByFile("/funspec.kt")
val element: PsiElement? = psiFile.elementAtLine(24)
element.shouldNotBeNull()
element.node.shouldBeInstanceOf<PsiWhiteSpace>()
element.startOffset shouldBe 361
element.endOffset shouldBe 369
element.node.shouldBeInstanceOf<PsiElement>()
element.startOffset shouldBe 369
element.endOffset shouldBe 373
}
}
45 changes: 0 additions & 45 deletions src/test/kotlin/io/kotest/plugin/intellij/psi/SpecTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,51 +21,6 @@ class SpecTests : LightJavaCodeInsightFixtureTestCase() {
return false
}

fun testIsContainedInSpecFunSpec() {

val psiFile = myFixture.configureByFiles(
"/funspec.kt",
"/io/kotest/core/spec/style/specs.kt"
)

runReadAction {
psiFile[0].elementAtLine(3)!!.isContainedInSpec() shouldBe false
for (k in 10..40) {
psiFile[0].elementAtLine(k)!!.isContainedInSpec() shouldBe true
}
}
}

fun testIsContainedInSpecStringSpec() {

val psiFile = myFixture.configureByFiles(
"/stringspec.kt",
"/io/kotest/core/spec/style/specs.kt"
)

runReadAction {
psiFile[0].elementAtLine(4)!!.isContainedInSpec() shouldBe false
for (k in 7..13) {
psiFile[0].elementAtLine(k)!!.isContainedInSpec() shouldBe true
}
}
}

fun testIsContainedInSpecFreeSpec() {

val psiFile = myFixture.configureByFiles(
"/freespec.kt",
"/io/kotest/core/spec/style/specs.kt"
)

runReadAction {
psiFile[0].elementAtLine(4)!!.isContainedInSpec() shouldBe false
for (k in 7..21) {
psiFile[0].elementAtLine(k)!!.isContainedInSpec() shouldBe true
}
}
}

fun testasKtClassOrObjectOrNull() {

val psiFile = myFixture.configureByFiles(
Expand Down

0 comments on commit 19cff14

Please sign in to comment.