Skip to content

Commit 8fdbba8

Browse files
committed
fix(devins-lang): replace "DevliError" with "DevInsError" for consistency and clarity.
1 parent df2bb82 commit 8fdbba8

File tree

5 files changed

+25
-14
lines changed

5 files changed

+25
-14
lines changed

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/DevInsCompiler.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class DevInsCompiler(private val myProject: Project, val file: DevInFile, val ed
156156

157157
val execResult = command.execute()
158158

159-
val isSucceed = execResult?.contains("<DevliError>") == false
159+
val isSucceed = execResult?.contains("<DevInsError>") == false
160160
val result = if (isSucceed) {
161161
val hasReadCodeBlock = commandNode == BuiltinCommand.WRITE
162162
|| commandNode == BuiltinCommand.PATCH
@@ -203,7 +203,7 @@ class SymbolInsCommand(val myProject: Project, val prop: String) :
203203
}
204204

205205
if (result.isEmpty()) {
206-
return "<DevliError> No symbol found: $prop"
206+
return "<DevInsError> No symbol found: $prop"
207207
}
208208

209209
return result.joinToString("\n")

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/exec/FileFuncInsCommand.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import com.intellij.openapi.vfs.VirtualFile
99
class FileFuncInsCommand(val myProject: Project, val prop: String) : InsCommand {
1010
override fun execute(): String? {
1111
val (functionName, args) = parseRegex(prop)
12-
val fileFunction = FileFunc.fromString(functionName) ?: return "<DevliError>: Unknown function: $functionName"
12+
val fileFunction = FileFunc.fromString(functionName) ?: return "<DevInsError>: Unknown function: $functionName"
1313
when (fileFunction) {
1414
FileFunc.Regex -> {
1515
try {
1616
val regex = Regex(args[0])
1717
return regexFunction(regex, myProject).joinToString(", ")
1818
} catch (e: Exception) {
19-
return "<DevliError>: ${e.message}"
19+
return "<DevInsError>: ${e.message}"
2020
}
2121
}
2222
}

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/exec/RunInsCommand.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ import com.intellij.psi.PsiManager
1515
*/
1616
class RunInsCommand(val myProject: Project, val prop: String) : InsCommand {
1717
override fun execute(): String? {
18-
val virtualFile = myProject.lookupFile(prop.trim()) ?: return "<DevliError>: File not found: $prop"
18+
val virtualFile = myProject.lookupFile(prop.trim()) ?: return "<DevInsError>: File not found: $prop"
1919
try {
2020
val psiFile: PsiFile =
21-
PsiManager.getInstance(myProject).findFile(virtualFile) ?: return "<DevliError>: File not found: $prop"
21+
PsiManager.getInstance(myProject).findFile(virtualFile) ?: return "<DevInsError>: File not found: $prop"
2222
val testService =
23-
AutoTestService.context(psiFile) ?: return "<DevliError>: No test service found for file: $prop"
23+
AutoTestService.context(psiFile) ?: return "<DevInsError>: No test service found for file: $prop"
2424
testService.runFile(myProject, virtualFile)
2525

2626
return "Running tests for file: $prop"
2727
} catch (e: Exception) {
28-
return "<DevliError>: ${e.message}"
28+
return "<DevInsError>: ${e.message}"
2929
}
3030
}
3131
}

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/exec/WriteInsCommand.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ class WriteInsCommand(val myProject: Project, val prop: String, val content: Str
1717
val filename = prop.split("#")[0]
1818

1919
try {
20-
val virtualFile = myProject.lookupFile(filename) ?: return "<DevliError>: File not found: $prop"
20+
val virtualFile = myProject.lookupFile(filename) ?: return "<DevInsError>: File not found: $prop"
2121
val psiFile = PsiManager.getInstance(myProject).findFile(virtualFile)
22-
?: return "<DevliError>: File not found: $prop"
22+
?: return "<DevInsError>: File not found: $prop"
2323
val document = PsiDocumentManager.getInstance(myProject).getDocument(psiFile)
24-
?: return "<DevliError>: File not found: $prop"
24+
?: return "<DevInsError>: File not found: $prop"
2525

2626
ApplicationManager.getApplication().invokeLater {
2727
WriteCommandAction.runWriteCommandAction(myProject) {
@@ -37,7 +37,7 @@ class WriteInsCommand(val myProject: Project, val prop: String, val content: Str
3737

3838
return "Writing to file: $prop"
3939
} catch (e: Exception) {
40-
return "<DevliError>: ${e.message}"
40+
return "<DevInsError>: ${e.message}"
4141
}
4242
}
4343
}

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/run/DevInsRunConfigurationProfileState.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,18 @@ open class DevInsRunConfigurationProfileState(
7070
val compiler = DevInsCompiler(myProject, file)
7171
val compileResult = compiler.compile()
7272

73-
console.print(compileResult.output, ConsoleViewContentType.USER_INPUT)
73+
val output = compileResult.output
74+
75+
// contains <DevInsError> means error
76+
output.split("\n").forEach {
77+
if (it.contains("<DevInsError>")) {
78+
console.print(it, ConsoleViewContentType.ERROR_OUTPUT)
79+
} else {
80+
console.print(it, ConsoleViewContentType.USER_INPUT)
81+
}
82+
console.print("\n", ConsoleViewContentType.NORMAL_OUTPUT)
83+
}
84+
7485
console.print("\n--------------------\n", ConsoleViewContentType.NORMAL_OUTPUT)
7586

7687
ApplicationManager.getApplication().invokeLater {
@@ -82,7 +93,7 @@ open class DevInsRunConfigurationProfileState(
8293

8394
LLMCoroutineScope.scope(myProject).launch {
8495
runBlocking {
85-
llm.stream(compileResult.output, "").collect {
96+
llm.stream(output, "").collect {
8697
console.print(it, ConsoleViewContentType.NORMAL_OUTPUT)
8798
}
8899
}

0 commit comments

Comments
 (0)