fun retrieveAny()

in robot-server-core/src/main/kotlin/com/intellij/remoterobot/services/IdeRobot.kt [343:364]


    fun retrieveAny(componentId: String, script: String, runInEdt: Boolean): Result<Serializable> {
        val componentContext = componentContextCache[componentId]
            ?: throw IllegalStateException("Unknown component id $componentId")

        return getResult(componentContext) { ctx ->
            if (runInEdt) {
                runInEdtWithWIL {
                    val result = jsExecutor.execute(script, ctx)
                    if (result != null && result is Serializable) {
                        return@runInEdtWithWIL result
                    }
                    throw ScriptMustReturnSerializableException(result)
                }
            } else {
                val result = jsExecutor.execute(script, ctx)
                if (result != null && result is Serializable) {
                    return@getResult result as Serializable
                }
                throw ScriptMustReturnSerializableException(result)
            }
        }
    }