@@ -5,6 +5,7 @@ import com.intellij.openapi.actionSystem.ActionUpdateThread
5
5
import com.intellij.openapi.actionSystem.AnActionEvent
6
6
import com.intellij.openapi.fileEditor.FileDocumentManager
7
7
import com.intellij.openapi.project.DumbAwareAction
8
+ import com.intellij.openapi.util.NlsSafe
8
9
import com.intellij.psi.PsiManager
9
10
10
11
class AutoDevRunDevInsAction : DumbAwareAction () {
@@ -17,17 +18,30 @@ class AutoDevRunDevInsAction : DumbAwareAction() {
17
18
val file = FileDocumentManager .getInstance().getFile(document) ? : return
18
19
19
20
val language = PsiManager .getInstance(project).findFile(file)?.language?.id ? : return
20
- e.presentation.isEnabled = language == " DevIn" && LanguagePromptProcessor .instance (language).isNotEmpty( )
21
+ e.presentation.isEnabled = language == " http request " || (language == " DevIn" && hasDevInProcessor (language))
21
22
}
22
23
24
+ private fun hasDevInProcessor (language : @NlsSafe String ) =
25
+ LanguagePromptProcessor .instance(language).isNotEmpty()
26
+
23
27
override fun actionPerformed (e : AnActionEvent ) {
24
28
val editor = e.getData(com.intellij.openapi.actionSystem.PlatformDataKeys .EDITOR ) ? : return
25
29
val project = e.project ? : return
26
30
27
31
val document = editor.document
28
32
val text = document.text
33
+ val file = FileDocumentManager .getInstance().getFile(document) ? : return
29
34
30
- LanguagePromptProcessor .instance(" DevIn" ).firstOrNull()?.compile(project, text)
31
- }
35
+ val language = PsiManager .getInstance(project).findFile(file)?.language?.id ? : return
36
+
37
+ when (language) {
38
+ " http request" -> {
39
+ // call http request processor
40
+ }
32
41
42
+ " DevIn" -> {
43
+ LanguagePromptProcessor .instance(" DevIn" ).firstOrNull()?.compile(project, text)
44
+ }
45
+ }
46
+ }
33
47
}
0 commit comments