diff --git a/src/main/kotlin/io/sajensen/specmate/GoToTestAction.kt b/src/main/kotlin/io/sajensen/specmate/GoToTestAction.kt new file mode 100644 index 0000000..56e2856 --- /dev/null +++ b/src/main/kotlin/io/sajensen/specmate/GoToTestAction.kt @@ -0,0 +1,31 @@ +package io.sajensen.specmate + +import com.intellij.openapi.actionSystem.AnAction +import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.fileEditor.FileEditorManager +import com.intellij.openapi.ui.Messages +import com.intellij.openapi.vfs.LocalFileSystem + +class GoToTestAction : AnAction("Test") { + + override fun actionPerformed(e: AnActionEvent) { + val project = e.project + val currentFile = e.getData(com.intellij.openapi.actionSystem.CommonDataKeys.VIRTUAL_FILE) + + if (project != null && currentFile != null) { + val testFilePath = currentFile.path.replaceFirst("src", "spec").replace(".clj", "_spec.clj") + val testFile = LocalFileSystem.getInstance().findFileByPath(testFilePath) + + if (testFile != null) { + FileEditorManager.getInstance(project).openFile(testFile, true) + } else { + Messages.showMessageDialog( + project, + "Test file not found: $testFilePath", + "File Not Found", + Messages.getInformationIcon() + ) + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 36c56ca..f3b4ea8 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -24,4 +24,10 @@ + + + + + \ No newline at end of file