mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[evaluation-plugin] LME-7 CodeGen. Support delay between requests in evaluation plugin
GitOrigin-RevId: 34aae34a2dcd2e2312ccdfbdabe5a07b041a73f2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2fa85150a2
commit
a3648aa3cb
@@ -11,7 +11,7 @@ sealed interface Action {
|
||||
val sessionId: UUID
|
||||
|
||||
enum class ActionType {
|
||||
MOVE_CARET, CALL_FEATURE, PRINT_TEXT, DELETE_RANGE, SELECT_RANGE, RENAME
|
||||
MOVE_CARET, CALL_FEATURE, PRINT_TEXT, DELETE_RANGE, SELECT_RANGE, RENAME, DELAY
|
||||
}
|
||||
|
||||
object JsonAdapter : JsonDeserializer<Action>, JsonSerializer<Action> {
|
||||
@@ -23,6 +23,7 @@ sealed interface Action {
|
||||
ActionType.DELETE_RANGE -> context.deserialize(json, DeleteRange::class.java)
|
||||
ActionType.SELECT_RANGE -> context.deserialize(json, SelectRange::class.java)
|
||||
ActionType.RENAME -> context.deserialize(json, Rename::class.java)
|
||||
ActionType.DELAY -> context.deserialize(json, Delay::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +59,10 @@ data class SelectRange internal constructor(override val sessionId: UUID, val be
|
||||
override val type: Action.ActionType = Action.ActionType.SELECT_RANGE
|
||||
}
|
||||
|
||||
data class Delay internal constructor(override val sessionId: UUID, val seconds: Int) : Action {
|
||||
override val type: Action.ActionType = Action.ActionType.DELAY
|
||||
}
|
||||
|
||||
data class TextRange(val start: Int, val end: Int)
|
||||
|
||||
|
||||
@@ -82,5 +87,6 @@ class ActionsBuilder {
|
||||
fun printText(text: String) = actions.add(PrintText(sessionId, text))
|
||||
fun deleteRange(begin: Int, end: Int) = actions.add(DeleteRange(sessionId, begin, end))
|
||||
fun selectRange(begin: Int, end: Int) = actions.add(SelectRange(sessionId, begin, end))
|
||||
fun delay(seconds: Int) = actions.add(Delay(sessionId, seconds))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.cce.interpreter
|
||||
|
||||
interface ActionsInvoker {
|
||||
@@ -7,6 +7,7 @@ interface ActionsInvoker {
|
||||
fun printText(text: String)
|
||||
fun deleteRange(begin: Int, end: Int)
|
||||
fun selectRange(begin: Int, end: Int)
|
||||
fun delay(seconds: Int)
|
||||
fun openFile(file: String): String
|
||||
fun closeFile(file: String)
|
||||
fun isOpen(file: String): Boolean
|
||||
|
||||
@@ -47,6 +47,7 @@ class Interpreter(private val invokersFactory: InvokersFactory,
|
||||
is PrintText -> actionsInvoker.printText(action.text)
|
||||
is DeleteRange -> actionsInvoker.deleteRange(action.begin, action.end)
|
||||
is SelectRange -> actionsInvoker.selectRange(action.begin, action.end)
|
||||
is Delay -> actionsInvoker.delay(action.seconds)
|
||||
}
|
||||
if (isCanceled) break
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.psi.PsiNameIdentifierOwner
|
||||
import com.intellij.psi.search.searches.ReferencesSearch
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import com.intellij.testFramework.TestModeFlags
|
||||
import com.intellij.util.progress.sleepCancellable
|
||||
import java.io.File
|
||||
|
||||
class CommonActionsInvoker(private val project: Project) : ActionsInvoker {
|
||||
@@ -94,6 +95,11 @@ class CommonActionsInvoker(private val project: Project) : ActionsInvoker {
|
||||
editor.scrollingModel.scrollToCaret(ScrollType.MAKE_VISIBLE)
|
||||
}
|
||||
|
||||
override fun delay(seconds: Int) {
|
||||
LOG.info("Delay for $seconds seconds")
|
||||
sleepCancellable(seconds * 1000L)
|
||||
}
|
||||
|
||||
override fun openFile(file: String): String = readActionInSmartMode(project) {
|
||||
LOG.info("Open file: $file")
|
||||
val virtualFile = LocalFileSystem.getInstance().findFileByIoFile(File(file))
|
||||
|
||||
Reference in New Issue
Block a user