From 6cbeffe4b25dffa2c3ac040c864c51e30bdfbb62 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Wed, 29 Mar 2017 22:21:15 +0300 Subject: [PATCH] Add kotlinx.coroutines to IDEA dependencies Add some cool coroutine-based stuff Like CoroutineDispatcher for EDT --- .idea/artifacts/KotlinPlugin.xml | 1 + .idea/libraries/kotlinx_coroutines_core.xml | 11 +++++++ idea/idea-core/idea-core.iml | 1 + .../kotlin/idea/core/util/CoroutineUtils.kt | 32 +++++++++++++++++++ idea/idea.iml | 1 + update_dependencies.xml | 7 ++++ 6 files changed, 53 insertions(+) create mode 100644 .idea/libraries/kotlinx_coroutines_core.xml create mode 100644 idea/idea-core/src/org/jetbrains/kotlin/idea/core/util/CoroutineUtils.kt diff --git a/.idea/artifacts/KotlinPlugin.xml b/.idea/artifacts/KotlinPlugin.xml index ceb9ba2a2b2..a93eea350b5 100644 --- a/.idea/artifacts/KotlinPlugin.xml +++ b/.idea/artifacts/KotlinPlugin.xml @@ -103,6 +103,7 @@ + diff --git a/.idea/libraries/kotlinx_coroutines_core.xml b/.idea/libraries/kotlinx_coroutines_core.xml new file mode 100644 index 00000000000..6982ee33904 --- /dev/null +++ b/.idea/libraries/kotlinx_coroutines_core.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/idea/idea-core/idea-core.iml b/idea/idea-core/idea-core.iml index a9a10941722..cd781279a31 100644 --- a/idea/idea-core/idea-core.iml +++ b/idea/idea-core/idea-core.iml @@ -16,5 +16,6 @@ + \ No newline at end of file diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/util/CoroutineUtils.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/util/CoroutineUtils.kt new file mode 100644 index 00000000000..572b4f09528 --- /dev/null +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/util/CoroutineUtils.kt @@ -0,0 +1,32 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.core.util + +import com.intellij.openapi.application.ApplicationManager +import kotlinx.coroutines.experimental.CoroutineDispatcher +import kotlin.coroutines.experimental.CoroutineContext + + +public object EDT : CoroutineDispatcher() { + override fun isDispatchNeeded(context: CoroutineContext): Boolean { + return !ApplicationManager.getApplication().isDispatchThread + } + + override fun dispatch(context: CoroutineContext, block: Runnable) { + ApplicationManager.getApplication().invokeLater(block) + } +} diff --git a/idea/idea.iml b/idea/idea.iml index 42c145bc532..6a7fef6a1d6 100644 --- a/idea/idea.iml +++ b/idea/idea.iml @@ -63,5 +63,6 @@ + \ No newline at end of file diff --git a/update_dependencies.xml b/update_dependencies.xml index f964493500a..41a04939a99 100644 --- a/update_dependencies.xml +++ b/update_dependencies.xml @@ -33,6 +33,8 @@ + + @@ -240,6 +242,11 @@ + + + +