Skip to content

Commit c997c95

Browse files
author
a.iudin
committed
Refactor PromptTextField suggestion UI to use custom JBPopup
Remove LookupUtil and all LookupImpl‐based code. Introduce JBPopup‐backed suggestion panel with SearchTextField and JBList, backed by LookupListModel and rendered by LookupListCellRenderer. Refactor DynamicLookupGroupItem to return item lists, add runCatchingCancellable utility, simplify event dispatcher and cleanup lookup cancellation.
1 parent 4e54a2f commit c997c95

File tree

11 files changed

+452
-191
lines changed

11 files changed

+452
-191
lines changed

src/main/kotlin/ee/carlrobert/codegpt/psistructure/PsiStructureProvider.kt

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@ import com.intellij.openapi.application.ReadAction
55
import com.intellij.psi.PsiFile
66
import com.intellij.util.io.await
77
import ee.carlrobert.codegpt.psistructure.models.ClassStructure
8-
import kotlinx.coroutines.Dispatchers
9-
import kotlinx.coroutines.asExecutor
10-
import kotlinx.coroutines.currentCoroutineContext
11-
import kotlinx.coroutines.delay
12-
import kotlinx.coroutines.ensureActive
8+
import ee.carlrobert.codegpt.util.coroutines.runCatchingCancellable
9+
import kotlinx.coroutines.*
1310
import org.jetbrains.kotlin.psi.KtFile
14-
import kotlin.coroutines.cancellation.CancellationException
1511

1612
class PsiStructureProvider {
1713

@@ -26,7 +22,7 @@ class PsiStructureProvider {
2622

2723
while (result == null && attempts < maxAttempts) {
2824
attempts++
29-
try {
25+
runCatchingCancellable {
3026
val project = psiFiles
3127
.map { it.project }
3228
.firstOrNull { !it.isDisposed } ?: error("Project not available")
@@ -60,9 +56,7 @@ class PsiStructureProvider {
6056
.submit(Dispatchers.Default.asExecutor())
6157

6258
result = future.await()
63-
} catch (e: CancellationException) {
64-
throw e
65-
} catch (_: Exception) {
59+
}.onFailure {
6660
delay(DELAY_RESTART_READ_ACTION)
6761
}
6862
}

0 commit comments

Comments
 (0)