Skip to content

Commit

Permalink
feat(devins-lang): add code parsing and notification for DevIns respo…
Browse files Browse the repository at this point in the history
…nse #146

This commit adds code parsing to ensure the correct language is detected before compiling and introduces a notification system to inform users of the compilation result.
  • Loading branch information
phodal committed Apr 11, 2024
1 parent 7ca9546 commit 2bf268b
Showing 1 changed file with 10 additions and 1 deletion.
Expand Up @@ -6,6 +6,7 @@ import cc.unitmesh.devti.language.compiler.DevInsCompiler
import cc.unitmesh.devti.language.psi.DevInFile
import cc.unitmesh.devti.provider.devins.CustomAgentContext
import cc.unitmesh.devti.provider.devins.LanguagePromptProcessor
import cc.unitmesh.devti.util.parser.Code
import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElement
Expand All @@ -17,7 +18,15 @@ class DevInsPromptProcessor : LanguagePromptProcessor {
override val name: String = DevInLanguage.displayName

override fun execute(project: Project, context: CustomAgentContext): String {
val devInsCompiler = createCompiler(project, context.response)
var text = context.response
// re-check the language of the code
Code.parse(text).let {
if (it.language == DevInLanguage.INSTANCE) {
text = it.text
}
}

val devInsCompiler = createCompiler(project, text)
val result = devInsCompiler.compile()
AutoDevNotifications.notify(project, result.output)
return result.output
Expand Down

0 comments on commit 2bf268b

Please sign in to comment.