Commit 67a06d83 authored by Kirill.Krylov's avatar Kirill.Krylov Committed by intellij-monorepo-bot
Browse files

[inline-completion] IDEA-333597 cleanup debug

GitOrigin-RevId: f0d8c880bdf67394ab1e56c1425c18285dae836f
parent 86e1e415
Showing with 7 additions and 18 deletions
+7 -18
......@@ -48,7 +48,6 @@ class InlineCompletionHandler(
init {
addEventListener(InlineCompletionUsageTracker.Listener())
addEventListener(InlineCompletionEventListener.Debug)
}
fun addEventListener(listener: InlineCompletionEventListener) {
......
......@@ -19,7 +19,7 @@ class InlineCompletionProviderManager {
*
* Temporary works for one provider only due to API limitations //TODO: add task
*/
private val suggestions = mutableMapOf<InlineCompletionProviderID, MutableList<List<InlineCompletionElement.Presentable>>>()
private val suggestions = mutableMapOf<InlineCompletionProviderID, MutableList<List<InlineCompletionElement>>>()
private var currentIndexes = mutableMapOf<InlineCompletionProviderID, Int>()
private var providerIndex: Int = 0
......@@ -27,11 +27,11 @@ class InlineCompletionProviderManager {
internal fun cacheSuggestion(providerId: InlineCompletionProviderID, elements: List<InlineCompletionElement.Presentable>) {
if (suggestions.containsKey(providerId)) {
val cachesPerProvider = suggestions.getValue(providerId)
cachesPerProvider.add(elements)
cachesPerProvider.add(elements.map { it.element.withSameContent() })
currentIndexes[providerId] = cachesPerProvider.size - 1
}
else {
suggestions[providerId] = mutableListOf(elements)
suggestions[providerId] = mutableListOf(elements.map { it.element.withSameContent() })
currentIndexes[providerId] = 0
}
}
......@@ -39,7 +39,7 @@ class InlineCompletionProviderManager {
internal fun getCache(providerId: InlineCompletionProviderID): List<InlineCompletionElement.Presentable>? {
val index = currentIndexes[providerId] ?: return null
val suggestion = suggestions[providerId] ?: return null
return suggestion.getOrNull(index)
return suggestion.getOrNull(index)?.map { it.toPresentable() }
}
internal fun clear() {
......
......@@ -13,23 +13,13 @@ sealed class InlineCompletionEventType {
data class Show(val element: InlineCompletionElement, val i: Int) : InlineCompletionEventType()
data class Change(val truncateTyping: Int) : InlineCompletionEventType()
object Empty : InlineCompletionEventType()
data object Empty : InlineCompletionEventType()
data class Completion(val cause: Throwable?, val isActive: Boolean) : InlineCompletionEventType()
object Insert : InlineCompletionEventType()
data object Insert : InlineCompletionEventType()
open class Hide(val explicit: Boolean) : InlineCompletionEventType()
}
interface InlineCompletionEventListener : EventListener {
object Debug : InlineCompletionEventAdapter {
override fun onRequest(event: InlineCompletionEventType.Request) = println("onRequest")
override fun onShow(event: InlineCompletionEventType.Show) = println("onShow")
override fun onChange(event: InlineCompletionEventType.Change) = println("onChange")
override fun onInsert(event: InlineCompletionEventType.Insert) = println("onInsert")
override fun onHide(event: InlineCompletionEventType.Hide) = println("onHide")
override fun onCompletion(event: InlineCompletionEventType.Completion) = println("onCompletion")
override fun onEmpty(event: InlineCompletionEventType.Empty) = println("onEmpty")
}
fun on(event: InlineCompletionEventType)
}
......
......@@ -9,7 +9,7 @@ import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
@TestOnly
val DEFAULT_TEST_TIMEOUT: Duration = 100.seconds
val DEFAULT_TEST_TIMEOUT: Duration = 10.seconds
@TestOnly
fun timeoutRunBlocking(timeout: Duration = DEFAULT_TEST_TIMEOUT, action: suspend CoroutineScope.() -> Unit) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment