Migrate to release coroutines
This commit is contained in:
committed by
Ilmir Usmanov
parent
bbc73ec0e5
commit
0191e3d1cf
+3
-4
@@ -123,8 +123,8 @@ extra["versions.junit"] = "4.12"
|
||||
extra["versions.javaslang"] = "2.0.6"
|
||||
extra["versions.ant"] = "1.8.2"
|
||||
extra["versions.android"] = "2.3.1"
|
||||
extra["versions.kotlinx-coroutines-core"] = "0.20"
|
||||
extra["versions.kotlinx-coroutines-jdk8"] = "0.20"
|
||||
extra["versions.kotlinx-coroutines-core"] = "0.26.1-eap13"
|
||||
extra["versions.kotlinx-coroutines-jdk8"] = "0.26.1-eap13"
|
||||
extra["versions.json"] = "20160807"
|
||||
extra["versions.native-platform"] = "0.14"
|
||||
extra["versions.ant-launcher"] = "1.8.0"
|
||||
@@ -274,8 +274,7 @@ allprojects {
|
||||
val commonCompilerArgs = listOfNotNull(
|
||||
"-Xallow-kotlin-package",
|
||||
"-Xread-deserialized-contracts",
|
||||
"-Xprogressive".takeIf { hasProperty("test.progressive.mode") }, // TODO: change to "-progressive" after bootstrap
|
||||
"-XXLanguage:-ReleaseCoroutines"
|
||||
"-Xprogressive".takeIf { hasProperty("test.progressive.mode") } // TODO: change to "-progressive" after bootstrap
|
||||
)
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.script
|
||||
|
||||
import kotlinx.coroutines.experimental.runBlocking
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlin.script.experimental.dependencies.DependenciesResolver
|
||||
import kotlin.script.dependencies.Environment
|
||||
import kotlin.script.dependencies.ScriptContents
|
||||
|
||||
@@ -45,7 +45,6 @@ import org.jetbrains.kotlin.resolve.TargetPlatform
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.storage.getValue
|
||||
import java.util.*
|
||||
import kotlin.coroutines.experimental.buildSequence
|
||||
|
||||
class ResolverForModule(
|
||||
val packageFragmentProvider: PackageFragmentProvider,
|
||||
@@ -346,7 +345,7 @@ class LazyModuleDependencies<M : ModuleInfo>(
|
||||
) : ModuleDependencies {
|
||||
private val dependencies = storageManager.createLazyValue {
|
||||
val moduleDescriptor = resolverForProject.descriptorForModule(module)
|
||||
buildSequence {
|
||||
sequence {
|
||||
if (firstDependency != null) {
|
||||
yield(resolverForProject.descriptorForModule(firstDependency))
|
||||
}
|
||||
|
||||
+2
-3
@@ -53,7 +53,6 @@ import org.jetbrains.kotlin.types.typeUtil.makeNullable
|
||||
import org.jetbrains.kotlin.utils.yieldIfNotNull
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
import kotlin.coroutines.experimental.buildSequence
|
||||
|
||||
sealed class DoubleColonLHS(val type: KotlinType) {
|
||||
/**
|
||||
@@ -715,13 +714,13 @@ class DoubleColonExpressionResolver(
|
||||
?.apply { commitTrace() }?.results
|
||||
}
|
||||
|
||||
val resultSequence = buildSequence {
|
||||
val resultSequence = sequence {
|
||||
when (lhs) {
|
||||
is DoubleColonLHS.Type -> {
|
||||
val classifier = lhsType.constructor.declarationDescriptor
|
||||
if (classifier !is ClassDescriptor) {
|
||||
c.trace.report(CALLABLE_REFERENCE_LHS_NOT_A_CLASS.on(expression))
|
||||
return@buildSequence
|
||||
return@sequence
|
||||
}
|
||||
|
||||
val qualifier = c.trace.get(BindingContext.QUALIFIER, expression.receiverExpression!!)
|
||||
|
||||
@@ -12,7 +12,6 @@ import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
import kotlin.coroutines.experimental.buildSequence
|
||||
import kotlin.script.templates.standard.ScriptTemplateWithArgs
|
||||
|
||||
class ScriptProviderTest : KtUsefulTestCase() {
|
||||
@@ -71,7 +70,7 @@ private class TestScriptDefinitionSource(val counter: AtomicInteger, val defGens
|
||||
{
|
||||
constructor(counter: AtomicInteger, vararg suffixes: String) : this(counter, suffixes.map { { FakeScriptDefinition(it) } })
|
||||
|
||||
override val definitions: Sequence<KotlinScriptDefinition> = buildSequence {
|
||||
override val definitions: Sequence<KotlinScriptDefinition> = sequence {
|
||||
for (gen in defGens) {
|
||||
counter.incrementAndGet()
|
||||
yield(gen())
|
||||
|
||||
@@ -17,13 +17,12 @@
|
||||
package org.jetbrains.kotlin.utils
|
||||
|
||||
import java.util.*
|
||||
import kotlin.coroutines.experimental.SequenceBuilder
|
||||
|
||||
fun <K, V> Iterable<K>.keysToMap(value: (K) -> V): Map<K, V> {
|
||||
return associateBy({ it }, value)
|
||||
}
|
||||
|
||||
fun <K, V: Any> Iterable<K>.keysToMapExceptNulls(value: (K) -> V?): Map<K, V> {
|
||||
fun <K, V : Any> Iterable<K>.keysToMapExceptNulls(value: (K) -> V?): Map<K, V> {
|
||||
val map = LinkedHashMap<K, V>()
|
||||
for (k in this) {
|
||||
val v = value(k)
|
||||
@@ -47,45 +46,44 @@ inline fun <K, V> MutableMap<K, V>.getOrPutNullable(key: K, defaultValue: () ->
|
||||
val answer = defaultValue()
|
||||
put(key, answer)
|
||||
answer
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
get(key) as V
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <T, C: Collection<T>> C.ifEmpty(body: () -> C): C = if (isEmpty()) body() else this
|
||||
inline fun <T, C : Collection<T>> C.ifEmpty(body: () -> C): C = if (isEmpty()) body() else this
|
||||
|
||||
inline fun <K, V, M: Map<K, V>> M.ifEmpty(body: () -> M): M = if (isEmpty()) body() else this
|
||||
inline fun <K, V, M : Map<K, V>> M.ifEmpty(body: () -> M): M = if (isEmpty()) body() else this
|
||||
|
||||
inline fun <T> Array<out T>.ifEmpty(body: () -> Array<out T>): Array<out T> = if (isEmpty()) body() else this
|
||||
|
||||
fun <T: Any> MutableCollection<T>.addIfNotNull(t: T?) {
|
||||
fun <T : Any> MutableCollection<T>.addIfNotNull(t: T?) {
|
||||
if (t != null) add(t)
|
||||
}
|
||||
|
||||
suspend fun <T: Any> SequenceBuilder<T>.yieldIfNotNull(t: T?) = if (t != null) yield(t) else Unit
|
||||
suspend fun <T : Any> SequenceScope<T>.yieldIfNotNull(t: T?) = if (t != null) yield(t) else Unit
|
||||
|
||||
fun <K, V> newHashMapWithExpectedSize(expectedSize: Int): HashMap<K, V> =
|
||||
HashMap(capacity(expectedSize))
|
||||
HashMap(capacity(expectedSize))
|
||||
|
||||
fun <E> newHashSetWithExpectedSize(expectedSize: Int): HashSet<E> =
|
||||
HashSet(capacity(expectedSize))
|
||||
HashSet(capacity(expectedSize))
|
||||
|
||||
fun <K, V> newLinkedHashMapWithExpectedSize(expectedSize: Int): LinkedHashMap<K, V> =
|
||||
LinkedHashMap(capacity(expectedSize))
|
||||
LinkedHashMap(capacity(expectedSize))
|
||||
|
||||
fun <E> newLinkedHashSetWithExpectedSize(expectedSize: Int): LinkedHashSet<E> =
|
||||
LinkedHashSet(capacity(expectedSize))
|
||||
LinkedHashSet(capacity(expectedSize))
|
||||
|
||||
private fun capacity(expectedSize: Int): Int =
|
||||
if (expectedSize < 3) 3 else expectedSize + expectedSize / 3 + 1
|
||||
if (expectedSize < 3) 3 else expectedSize + expectedSize / 3 + 1
|
||||
|
||||
fun <T> ArrayList<T>.compact(): List<T> =
|
||||
when (size) {
|
||||
0 -> emptyList()
|
||||
1 -> listOf(first())
|
||||
else -> apply { trimToSize() }
|
||||
}
|
||||
when (size) {
|
||||
0 -> emptyList()
|
||||
1 -> listOf(first())
|
||||
else -> apply { trimToSize() }
|
||||
}
|
||||
|
||||
fun <T> List<T>.indexOfFirst(startFrom: Int, predicate: (T) -> Boolean): Int {
|
||||
for (index in startFrom..lastIndex) {
|
||||
|
||||
@@ -30,7 +30,6 @@ import org.jetbrains.kotlin.script.findScriptDefinition
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.kotlin.utils.sure
|
||||
import org.jetbrains.kotlin.utils.yieldIfNotNull
|
||||
import kotlin.coroutines.experimental.buildSequence
|
||||
|
||||
var PsiFile.forcedModuleInfo: ModuleInfo? by UserDataProperty(Key.create("FORCED_MODULE_INFO"))
|
||||
|
||||
@@ -121,7 +120,7 @@ private sealed class ModuleInfoCollector<out T>(
|
||||
emptySequence()
|
||||
},
|
||||
virtualFileProcessor = { project, virtualFile, isLibrarySource ->
|
||||
buildSequence {
|
||||
sequence {
|
||||
collectInfosByVirtualFile(
|
||||
project,
|
||||
virtualFile,
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.completion
|
||||
|
||||
import kotlinx.coroutines.experimental.channels.ConflatedChannel
|
||||
import kotlinx.coroutines.channels.ConflatedChannel
|
||||
import java.lang.System.currentTimeMillis
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.intellij.psi.PsiElementFinder
|
||||
import com.intellij.psi.PsiManager
|
||||
import com.intellij.psi.search.NonClasspathDirectoriesScope
|
||||
import com.intellij.util.containers.SLRUMap
|
||||
import kotlinx.coroutines.experimental.launch
|
||||
import kotlinx.coroutines.launch
|
||||
import org.jetbrains.kotlin.idea.core.util.EDT
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import java.io.File
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.idea.core.script.dependencies
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import kotlinx.coroutines.experimental.*
|
||||
import kotlinx.coroutines.*
|
||||
import org.jetbrains.kotlin.idea.core.script.settings.KotlinScriptingSettings
|
||||
import org.jetbrains.kotlin.idea.core.util.cancelOnDisposal
|
||||
import org.jetbrains.kotlin.script.KotlinScriptDefinition
|
||||
|
||||
@@ -22,10 +22,10 @@ import com.intellij.openapi.application.ModalityState
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import kotlinx.coroutines.experimental.CoroutineDispatcher
|
||||
import kotlinx.coroutines.experimental.Job
|
||||
import kotlin.coroutines.experimental.AbstractCoroutineContextElement
|
||||
import kotlin.coroutines.experimental.CoroutineContext
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlin.coroutines.AbstractCoroutineContextElement
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
|
||||
public object EDT : CoroutineDispatcher() {
|
||||
|
||||
+4
-4
@@ -36,10 +36,10 @@ import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.ui.components.JBLabel
|
||||
import com.intellij.ui.components.JBTextField
|
||||
import com.intellij.uiDesigner.core.GridConstraints
|
||||
import kotlinx.coroutines.experimental.CancellationException
|
||||
import kotlinx.coroutines.experimental.delay
|
||||
import kotlinx.coroutines.experimental.launch
|
||||
import kotlinx.coroutines.experimental.withTimeout
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withTimeout
|
||||
import org.jetbrains.kotlin.idea.KotlinFileType
|
||||
import org.jetbrains.kotlin.idea.caches.project.ModuleOrigin
|
||||
import org.jetbrains.kotlin.idea.caches.project.getNullableModuleInfo
|
||||
|
||||
+3
-3
@@ -32,9 +32,9 @@ import com.intellij.psi.PsiDocumentManager
|
||||
import com.intellij.ui.components.JBPanel
|
||||
import com.intellij.ui.components.JBTextField
|
||||
import com.intellij.uiDesigner.core.GridLayoutManager
|
||||
import kotlinx.coroutines.experimental.channels.ConflatedChannel
|
||||
import kotlinx.coroutines.experimental.delay
|
||||
import kotlinx.coroutines.experimental.launch
|
||||
import kotlinx.coroutines.channels.ConflatedChannel
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import org.jetbrains.kotlin.idea.actions.internal.benchmark.AbstractCompletionBenchmarkAction.Companion.addBoxWithLabel
|
||||
import org.jetbrains.kotlin.idea.actions.internal.benchmark.AbstractCompletionBenchmarkAction.Companion.collectSuitableKotlinFiles
|
||||
import org.jetbrains.kotlin.idea.actions.internal.benchmark.AbstractCompletionBenchmarkAction.Companion.shuffledSequence
|
||||
|
||||
@@ -34,8 +34,6 @@ import org.jetbrains.kotlin.psi.KtEscapeStringTemplateEntry
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtStringTemplateExpression
|
||||
import org.jetbrains.kotlin.psi.psiUtil.*
|
||||
import kotlin.coroutines.experimental.SequenceBuilder
|
||||
import kotlin.coroutines.experimental.buildIterator
|
||||
|
||||
private val PsiElement.templateContentRange: TextRange?
|
||||
get() = this.getParentOfType<KtStringTemplateExpression>(false)?.let{
|
||||
@@ -219,7 +217,7 @@ private class TemplateTokenSequence(private val inputString: String) : Sequence<
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun SequenceBuilder<TemplateChunk>.yieldLiteral(chunk: String) {
|
||||
private suspend fun SequenceScope<TemplateChunk>.yieldLiteral(chunk: String) {
|
||||
val splitLines = LineTokenizer.tokenize(chunk, false, false)
|
||||
for (i in 0..splitLines.size - 1) {
|
||||
if (i != 0) {
|
||||
@@ -233,7 +231,7 @@ private class TemplateTokenSequence(private val inputString: String) : Sequence<
|
||||
if (inputString.isEmpty()) {
|
||||
return emptySequence<TemplateChunk>().iterator()
|
||||
}
|
||||
return buildIterator {
|
||||
return iterator {
|
||||
var from = 0
|
||||
var to = 0
|
||||
while (to < inputString.length) {
|
||||
|
||||
@@ -23,8 +23,8 @@ import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiRecursiveElementVisitor
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager
|
||||
import kotlinx.coroutines.experimental.run
|
||||
import kotlinx.coroutines.experimental.runBlocking
|
||||
import kotlinx.coroutines.run
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.resolveImportReference
|
||||
import org.jetbrains.kotlin.idea.conversion.copy.range
|
||||
|
||||
+2
-2
@@ -18,8 +18,8 @@
|
||||
|
||||
package kotlin.script.experimental.host
|
||||
|
||||
import kotlinx.coroutines.experimental.CoroutineScope
|
||||
import kotlinx.coroutines.experimental.runBlocking
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlin.script.experimental.api.*
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
package kotlin.script.experimental.jvm.impl
|
||||
|
||||
import kotlinx.coroutines.experimental.runBlocking
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import java.io.File
|
||||
import kotlin.script.dependencies.Environment
|
||||
import kotlin.script.dependencies.ScriptContents
|
||||
|
||||
Reference in New Issue
Block a user