Skip to content

Commit 5e68d61

Browse files
committed
feat(python): add Python language support to WriteTestService
This commit adds support for the Python language in the WriteTestService class of the PyCharm provider. The `isApplicable` method now checks if the element's language is PythonLanguage. Additionally, the `runConfigurationClass` method is overridden to return the PythonRunConfiguration class.
1 parent ddbead7 commit 5e68d61

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

pycharm/src/main/kotlin/cc/unitmesh/pycharm/provider/PythonWriteTestService.kt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@ import com.intellij.psi.PsiElement
1111
import com.intellij.psi.PsiFile
1212
import com.intellij.psi.util.PsiTreeUtil
1313
import com.intellij.psi.util.PsiUtilBase
14+
import com.jetbrains.python.PythonLanguage
1415
import com.jetbrains.python.psi.PyClass
1516
import com.jetbrains.python.psi.PyFunction
17+
import com.jetbrains.python.run.PythonRunConfiguration
1618

1719
class PythonWriteTestService : WriteTestService() {
20+
override fun isApplicable(element: PsiElement): Boolean = element.language is PythonLanguage
21+
22+
override fun runConfigurationClass(project: Project): Class<out RunProfile> = PythonRunConfiguration::class.java
23+
1824
fun getElementForTests(project: Project, editor: Editor): PsiElement? {
1925
val element = PsiUtilBase.getElementAtCaret(editor) ?: return null
2026
val containingFile: PsiFile = element.containingFile ?: return null
@@ -34,14 +40,6 @@ class PythonWriteTestService : WriteTestService() {
3440
return PsiTreeUtil.getParentOfType(element, PyClass::class.java, false) ?: containingFile
3541
}
3642

37-
override fun runConfigurationClass(project: Project): Class<out RunProfile> {
38-
TODO("Not yet implemented")
39-
}
40-
41-
override fun isApplicable(element: PsiElement): Boolean {
42-
TODO("Not yet implemented")
43-
}
44-
4543
override fun findOrCreateTestFile(sourceFile: PsiFile, project: Project, element: PsiElement): TestFileContext? {
4644
TODO("Not yet implemented")
4745
}

0 commit comments

Comments
 (0)