Skip to content

Commit 9f48eec

Browse files
committed
feat(indexer): enhance domain dictionary generation with logging and error handling
- Add logging for the generated prompt - Implement directory creation if it doesn't exist- Improve error handling for file operations
1 parent 37e8114 commit 9f48eec

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

core/src/main/kotlin/cc/unitmesh/devti/indexer/DomainDictGenerateAction.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ import com.intellij.openapi.project.guessProjectDir
1616
import kotlinx.coroutines.launch
1717
import cc.unitmesh.devti.AutoDevIcons
1818
import com.intellij.openapi.actionSystem.Presentation
19+
import com.intellij.openapi.diagnostic.logger
20+
import kotlin.io.path.createDirectories
21+
import kotlin.io.path.exists
1922

2023
class DomainDictGenerateAction : AnAction() {
2124
init {
@@ -38,14 +41,21 @@ class DomainDictGenerateAction : AnAction() {
3841
try {
3942
updatePresentation(presentation, AutoDevIcons.InProgress, false)
4043
AutoDevStatusService.notifyApplication(AutoDevStatus.InProgress)
41-
44+
45+
logger<DomainDictGenerateAction>().debug("Prompt: $prompt")
46+
4247
val result = StringBuilder()
4348
LlmFactory.create(project).stream(prompt, "").collect {
4449
result.append(it)
4550
}
4651

4752
val dict = result.toString()
48-
val file = project.guessProjectDir()!!.toNioPath().resolve(baseDir).resolve("domain.csv").toFile()
53+
val resolve = project.guessProjectDir()!!.toNioPath().resolve(baseDir)
54+
if (!resolve.exists()) {
55+
resolve.createDirectories()
56+
}
57+
58+
val file = resolve.resolve("domain.csv").toFile()
4959
if (!file.exists()) {
5060
file.createNewFile()
5161
}

core/src/main/kotlin/cc/unitmesh/devti/indexer/usage/PromptEnhancer.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import cc.unitmesh.devti.template.context.TemplateContext
99
import com.intellij.openapi.components.Service
1010
import com.intellij.openapi.project.Project
1111
import com.intellij.openapi.project.guessProjectDir
12+
import com.intellij.openapi.diagnostic.logger
1213

1314
@Service(Service.Level.PROJECT)
1415
class PromptEnhancer(val project: Project) {

0 commit comments

Comments
 (0)