Skip to content

Commit bf2ff08

Browse files
committed
refactor(devti): replace ProgressManager with coroutines for async task
- Remove usage of ProgressManager.getInstance().runProcessWithProgressSynchronously - Use AutoDevCoroutineScope.workerScope(project).launch for asynchronous task - Simplify code structure and improve readability - This change prepares for integrating the new design of com.intellij.openapi.progress.impl.CoreProgressManager, which may contain breaking changes for ProgressManager usages
1 parent 825fc65 commit bf2ff08

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

core/src/main/kotlin/cc/unitmesh/devti/sketch/SketchInputListener.kt

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,24 +85,18 @@ open class SketchInputListener(
8585
val input = userInput.trim()
8686
if (input.isEmpty() || input.isBlank()) return
8787
if (input == "\n") return
88-
89-
// if length < 10, logger for debug
9088
if (input.length < 10) {
9189
logger<SketchInputListener>().debug("Input.length < 10: $input")
9290
}
9391

9492
logger<SketchInputListener>().debug("Start compiling: $input")
95-
ProgressManager.getInstance().runProcessWithProgressSynchronously({
93+
AutoDevCoroutineScope.workerScope(project).launch {
9694
val devInProcessor = LanguageProcessor.devin()
97-
val compiledInput = runReadAction {
98-
runBlocking {
99-
devInProcessor?.compile(project, input)
100-
}
101-
} ?: input
95+
val compiledInput = devInProcessor?.compile(project, input) ?: input
10296

10397
val input = compiledInput.toString().trim()
10498
if (input.isEmpty()) {
105-
return@runProcessWithProgressSynchronously
99+
return@launch
106100
}
107101

108102
toolWindow.beforeRun()
@@ -120,7 +114,7 @@ open class SketchInputListener(
120114

121115
toolWindow.onFinish(suggestion.toString())
122116
}
123-
}, AutoDevBundle.message("sketch.compile.devins"), false, project);
117+
}
124118
}
125119

126120
override fun dispose() {

0 commit comments

Comments
 (0)