Replace deprecated toMap usages with toMapBy

This commit is contained in:
Ilya Gorbunov
2015-11-30 04:00:31 +03:00
parent f107559a3c
commit ea60ab74a7
11 changed files with 13 additions and 13 deletions
@@ -47,7 +47,7 @@ interface Conditional {
companion object {
val ANNOTATIONS: Map<String, Parser> = listOf<Parser>(JvmVersion, JsVersion, TargetName).toMap { it.name }
val ANNOTATIONS: Map<String, Parser> = listOf<Parser>(JvmVersion, JsVersion, TargetName).toMapBy { it.name }
}
}
@@ -67,7 +67,7 @@ public interface AbstractSMAPBaseTest {
}.map {
val smap = it.getValue().mapNotNull { it.smap?.replaceHash() }.joinToString("\n")
SMAPAndFile(if (smap.isNotEmpty()) smap else null, it.key)
}.toMap { it.sourceFile }
}.toMapBy { it.sourceFile }
for (source in sourceData) {
val data = compiledData[source.sourceFile]
@@ -2,4 +2,4 @@ fun foo(list: List<String>) {
list.<caret>
}
// EXIST: { itemText: "firstOrNull", tailText: " {...} (predicate: (String) -> Boolean) for Iterable<T> in kotlin", typeText: "String?" }
// EXIST: { itemText: "toMap", tailText: " {...} (selector: (String) -> K) for Iterable<T> in kotlin", typeText: "Map<K, String>" }
// EXIST: { itemText: "toMapBy", tailText: " {...} (selector: (String) -> K) for Iterable<T> in kotlin", typeText: "Map<K, String>" }
@@ -52,7 +52,7 @@ public fun Call.mapArgumentsToParameters(targetDescriptor: CallableDescriptor):
if (parameters.isEmpty()) return emptyMap()
val map = HashMap<ValueArgument, ValueParameterDescriptor>()
val parametersByName = parameters.toMap { it.getName() }
val parametersByName = parameters.toMapBy { it.getName() }
var positionalArgumentIndex: Int? = 0
@@ -61,7 +61,7 @@ public abstract class AbstractMemberPullPushTest : KotlinLightCodeInsightFixture
val extraFiles = mainFile.parentFile.listFiles { file, name ->
name != mainFileName && name.startsWith("$mainFileBaseName.") && (name.endsWith(".kt") || name.endsWith(".java"))
}
val extraFilesToPsi = extraFiles.toMap { fixture.configureByFile(it.getName()) }
val extraFilesToPsi = extraFiles.toMapBy { fixture.configureByFile(it.getName()) }
val file = fixture.configureByFile(mainFileName)
val addKotlinRuntime = InTextDirectivesUtils.findStringWithPrefixes(file.text, "// WITH_RUNTIME") != null
@@ -319,7 +319,7 @@ public abstract class AbstractExtractionTest() : KotlinLightCodeInsightFixtureTe
val extraFiles = mainFile.getParentFile().listFiles { file, name ->
name != mainFileName && name.startsWith("$mainFileBaseName.") && (name.endsWith(".kt") || name.endsWith(".java"))
}
val extraFilesToPsi = extraFiles.toMap { fixture.configureByFile(it.getName()) }
val extraFilesToPsi = extraFiles.toMapBy { fixture.configureByFile(it.getName()) }
val file = fixture.configureByFile(mainFileName)
val addKotlinRuntime = InTextDirectivesUtils.findStringWithPrefixes(file.getText(), "// WITH_RUNTIME") != null
@@ -36,8 +36,8 @@ public abstract class AbstractProtoComparisonTest : UsefulTestCase() {
val oldClassFiles = compileFileAndGetClasses(testDataPath, testDir, "old")
val newClassFiles = compileFileAndGetClasses(testDataPath, testDir, "new")
val oldClassMap = oldClassFiles.toMap { it.name }
val newClassMap = newClassFiles.toMap { it.name }
val oldClassMap = oldClassFiles.toMapBy { it.name }
val newClassMap = newClassFiles.toMapBy { it.name }
val sb = StringBuilder()
val p = Printer(sb)
@@ -161,7 +161,7 @@ public enum class CharCategory(public val value: Int, public val code: String) {
public companion object {
private val categoryMap by lazy { CharCategory.values().toMap { it.value } }
private val categoryMap by lazy { CharCategory.values().toMapBy { it.value } }
public fun valueOf(category: Int): CharCategory = categoryMap[category] ?: throw IllegalArgumentException("Category #$category is not defined.")
}
@@ -110,7 +110,7 @@ public enum class CharDirectionality(public val value: Int) {
public companion object {
private val directionalityMap by lazy { CharDirectionality.values().toMap { it.value } }
private val directionalityMap by lazy { CharDirectionality.values().toMapBy { it.value } }
public fun valueOf(directionality: Int): CharDirectionality = directionalityMap[directionality] ?: throw IllegalArgumentException("Directionality #$directionality is not defined.")
}
+2 -2
View File
@@ -170,11 +170,11 @@ fun mapDefinitions(repository: Repository, definitions: Iterable<InterfaceDefini
definitions.filter { "NoInterfaceObject" !in it.extendedAttributes.map { it.call } }.map { generateTrait(repository, it) }
fun generateUnions(ifaces: List<GenerateTraitOrClass>, typedefs: Iterable<TypedefDefinition>): GenerateUnionTypes {
val declaredTypes = ifaces.toMap { it.name }
val declaredTypes = ifaces.toMapBy { it.name }
val anonymousUnionTypes = collectUnionTypes(declaredTypes)
val anonymousUnionTypeTraits = generateUnionTypeTraits(anonymousUnionTypes)
val anonymousUnionsMap = anonymousUnionTypeTraits.toMap { it.name }
val anonymousUnionsMap = anonymousUnionTypeTraits.toMapBy { it.name }
val typedefsToBeGenerated = typedefs.filter { it.types is UnionType }
.map { NamedValue(it.name, it.types as UnionType) }
@@ -227,7 +227,7 @@ private fun Pair<String, String>.betterName() = if (((0..9).map { it.toString()
fun <K, V> List<Pair<K, V>>.toMultiMap(): Map<K, List<V>> = groupBy { it.first }.mapValues { it.value.map { it.second } }
fun Appendable.render(namespace: String, ifaces: List<GenerateTraitOrClass>, unions : GenerateUnionTypes) {
val declaredTypes = ifaces.toMap { it.name }
val declaredTypes = ifaces.toMapBy { it.name }
val allTypes = declaredTypes + unions.anonymousUnionsMap + unions.typedefsMarkersMap
declaredTypes.values.filter { it.namespace == namespace }.forEach {