File tree Expand file tree Collapse file tree 3 files changed +36
-2
lines changed
exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language Expand file tree Collapse file tree 3 files changed +36
-2
lines changed Original file line number Diff line number Diff line change 1
1
package cc.unitmesh.devti.language.compiler
2
2
3
3
import cc.unitmesh.devti.agent.model.CustomAgentConfig
4
+ import cc.unitmesh.devti.language.psi.DevInFile
4
5
5
6
data class DevInsCompiledResult (
6
7
/* *
@@ -13,6 +14,10 @@ data class DevInsCompiledResult(
13
14
var output : String = " " ,
14
15
var isLocalCommand : Boolean = false ,
15
16
var hasError : Boolean = false ,
16
- var executeAgent : CustomAgentConfig ? = null
17
+ var executeAgent : CustomAgentConfig ? = null ,
18
+ /* *
19
+ * Next job to be executed
20
+ */
21
+ var nextJob : DevInFile ? = null
17
22
) {
18
23
}
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import cc.unitmesh.devti.language.psi.DevInUsed
14
14
import com.intellij.openapi.diagnostic.logger
15
15
import com.intellij.openapi.editor.Editor
16
16
import com.intellij.openapi.project.Project
17
+ import com.intellij.openapi.project.guessProjectDir
17
18
import com.intellij.psi.PsiElement
18
19
import com.intellij.psi.util.elementType
19
20
import kotlinx.coroutines.runBlocking
@@ -48,10 +49,23 @@ class DevInsCompiler(
48
49
49
50
output.append(it.text)
50
51
}
52
+
51
53
DevInTypes .USED -> processUsed(it as DevInUsed )
52
54
DevInTypes .COMMENTS -> {
53
- // ignore comment
55
+ if (it.text.startsWith(" [flow]:" )) {
56
+ val fileName = it.text.substringAfter(" [flow]:" ).trim()
57
+ val content =
58
+ myProject.guessProjectDir()?.findFileByRelativePath(fileName)?.let { virtualFile ->
59
+ virtualFile.inputStream.bufferedReader().use { reader -> reader.readText() }
60
+ }
61
+
62
+ if (content != null ) {
63
+ val devInFile = DevInFile .fromString(myProject, content)
64
+ result.nextJob = devInFile
65
+ }
66
+ }
54
67
}
68
+
55
69
else -> {
56
70
output.append(it.text)
57
71
logger.warn(" Unknown element type: ${it.elementType} " )
Original file line number Diff line number Diff line change @@ -29,6 +29,14 @@ class DevInsPromptProcessor : LanguagePromptProcessor {
29
29
val devInsCompiler = createCompiler(project, text)
30
30
val result = devInsCompiler.compile()
31
31
AutoDevNotifications .notify(project, result.output)
32
+
33
+ if (result.nextJob != null ) {
34
+ val nextJob = result.nextJob!!
35
+ val nextResult = createCompiler(project, nextJob).compile()
36
+ AutoDevNotifications .notify(project, nextResult.output)
37
+ return nextResult.output
38
+ }
39
+
32
40
return result.output
33
41
}
34
42
@@ -50,6 +58,13 @@ class DevInsPromptProcessor : LanguagePromptProcessor {
50
58
text : String
51
59
): DevInsCompiler {
52
60
val devInFile = DevInFile .fromString(project, text)
61
+ return createCompiler(project, devInFile)
62
+ }
63
+
64
+ private fun createCompiler (
65
+ project : Project ,
66
+ devInFile : DevInFile
67
+ ): DevInsCompiler {
53
68
val editor = FileEditorManager .getInstance(project).selectedTextEditor
54
69
val element: PsiElement ? = editor?.caretModel?.currentCaret?.offset?.let {
55
70
val psiFile = PsiUtilBase .getPsiFileInEditor(editor, project) ? : return @let null
You can’t perform that action at this time.
0 commit comments