Skip to content

Commit ce4baad

Browse files
committed
feat(webstorm): add guessTestFrameworkName utility function
This commit adds the `guessTestFrameworkName` utility function to the `JsUtil` class in the `webstorm` module. This function is used to determine the test framework name for a given JavaScript file.
1 parent 9acb8b9 commit ce4baad

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package cc.unitmesh.ide.webstorm.util
2+
3+
import com.intellij.psi.PsiFile
4+
5+
object JsUtil {
6+
fun guessTestFrameworkName(file: PsiFile): String? {
7+
return null
8+
}
9+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package cc.unitmesh.ide.webstorm.util
2+
3+
import com.intellij.javascript.testing.JSTestRunnerManager
4+
import com.intellij.psi.PsiFile
5+
6+
object JsUtil {
7+
fun guessTestFrameworkName(file: PsiFile): String? {
8+
val findPackageDependentProducers =
9+
JSTestRunnerManager.getInstance().findPackageDependentProducers(file)
10+
11+
val testRunConfigurationProducer = findPackageDependentProducers.firstOrNull()
12+
return testRunConfigurationProducer?.configurationType?.displayName
13+
}
14+
}

webstorm/src/main/kotlin/cc/unitmesh/ide/webstorm/provider/JavaScriptContextProvider.kt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import cc.unitmesh.devti.provider.context.ChatContextProvider
66
import cc.unitmesh.devti.provider.context.ChatCreationContext
77
import cc.unitmesh.ide.webstorm.JsDependenciesSnapshot
88
import cc.unitmesh.ide.webstorm.LanguageApplicableUtil
9+
import cc.unitmesh.ide.webstorm.util.JsUtil.guessTestFrameworkName
910
import com.intellij.javascript.nodejs.PackageJsonDependency
1011
import com.intellij.javascript.testing.JSTestRunnerManager
1112
import com.intellij.openapi.diagnostic.logger
@@ -80,14 +81,6 @@ class JavaScriptContextProvider : ChatContextProvider {
8081
)
8182
}
8283

83-
private fun guessTestFrameworkName(file: PsiFile): String? {
84-
val findPackageDependentProducers =
85-
JSTestRunnerManager.getInstance().findPackageDependentProducers(file)
86-
87-
val testRunConfigurationProducer = findPackageDependentProducers.firstOrNull()
88-
return testRunConfigurationProducer?.configurationType?.displayName
89-
}
90-
9184
private fun getTypeScriptLanguageContext(snapshot: JsDependenciesSnapshot): ChatContextItem? {
9285
val packageJson = snapshot.packages["typescript"] ?: return null
9386
val version = packageJson.parseVersion()

0 commit comments

Comments
 (0)