StdLib cleanup, deprecated symbol usage: List and Map members
This commit is contained in:
@@ -505,10 +505,10 @@ fun parseIDL(reader: CharStream): Repository {
|
||||
ModuleVisitor(declarations).visit(idl)
|
||||
|
||||
return Repository(
|
||||
declarations.filterIsInstance<InterfaceDefinition>().filter { it.name.isEmpty().not() }.groupBy { it.name }.mapValues { it.getValue().reduce(::merge) },
|
||||
declarations.filterIsInstance<TypedefDefinition>().groupBy { it.name }.mapValues { it.getValue().first() },
|
||||
declarations.filterIsInstance<ExtensionInterfaceDefinition>().groupBy { it.name }.mapValues { it.getValue().map { it.implements } },
|
||||
declarations.filterIsInstance<EnumDefinition>().groupBy { it.name }.mapValues { it.getValue().reduce { a, b -> a } }
|
||||
declarations.filterIsInstance<InterfaceDefinition>().filter { it.name.isEmpty().not() }.groupBy { it.name }.mapValues { it.value.reduce(::merge) },
|
||||
declarations.filterIsInstance<TypedefDefinition>().groupBy { it.name }.mapValues { it.value.first() },
|
||||
declarations.filterIsInstance<ExtensionInterfaceDefinition>().groupBy { it.name }.mapValues { it.value.map { it.implements } },
|
||||
declarations.filterIsInstance<EnumDefinition>().groupBy { it.name }.mapValues { it.value.reduce { a, b -> a } }
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ fun main(args: Array<String>) {
|
||||
|
||||
val repository = repositoryPre.copy(typeDefs = repositoryPre.typeDefs.mapValues { it.value.copy(mapType(repositoryPre, it.value.types)) })
|
||||
|
||||
val definitions = mapDefinitions(repository, repository.interfaces.values()).map {
|
||||
val definitions = mapDefinitions(repository, repository.interfaces.values).map {
|
||||
if (it.name in relocations) {
|
||||
// we need this to get interfaces listed in the relocations in valid package
|
||||
// to keep compatibility with DOM Java API
|
||||
@@ -35,7 +35,7 @@ fun main(args: Array<String>) {
|
||||
it
|
||||
}
|
||||
}
|
||||
val unions = generateUnions(definitions, repository.typeDefs.values())
|
||||
val unions = generateUnions(definitions, repository.typeDefs.values)
|
||||
val allPackages = definitions.map { it.namespace }.distinct().sorted()
|
||||
|
||||
outDir.deleteRecursively()
|
||||
|
||||
@@ -112,7 +112,7 @@ fun Appendable.render(allTypes: Map<String, GenerateTraitOrClass>, typeNamesToUn
|
||||
append(iface.name)
|
||||
val primary = iface.primaryConstructor
|
||||
if (primary != null && (primary.constructor.arguments.isNotEmpty() || iface.secondaryConstructors.isNotEmpty())) {
|
||||
renderArgumentsDeclaration(primary.constructor.fixRequiredArguments(iface.name).arguments.dynamicIfUnknownType(allTypes.keySet()), false)
|
||||
renderArgumentsDeclaration(primary.constructor.fixRequiredArguments(iface.name).arguments.dynamicIfUnknownType(allTypes.keys), false)
|
||||
}
|
||||
|
||||
val superCallName = primary?.initTypeCall?.name
|
||||
@@ -130,7 +130,7 @@ fun Appendable.render(allTypes: Map<String, GenerateTraitOrClass>, typeNamesToUn
|
||||
iface.secondaryConstructors.forEach { secondary ->
|
||||
indent(false, 1)
|
||||
append("constructor")
|
||||
renderArgumentsDeclaration(secondary.constructor.fixRequiredArguments(iface.name).arguments.dynamicIfUnknownType(allTypes.keySet()), false)
|
||||
renderArgumentsDeclaration(secondary.constructor.fixRequiredArguments(iface.name).arguments.dynamicIfUnknownType(allTypes.keys), false)
|
||||
|
||||
if (secondary.initTypeCall != null) {
|
||||
append(" : ")
|
||||
@@ -146,9 +146,9 @@ fun Appendable.render(allTypes: Map<String, GenerateTraitOrClass>, typeNamesToUn
|
||||
val superSignatures = superAttributes.map { it.signature } merge superFunctions.map { it.signature }
|
||||
|
||||
iface.memberAttributes
|
||||
.filter { it !in superAttributes && !it.static && (it.isVar || (it.isVal && superAttributesByName[it.name]?.hasNoVars() ?: true)) }
|
||||
.map { it.dynamicIfUnknownType(allTypes.keySet()) }
|
||||
.groupBy { it.signature }.reduceValues().values().forEach { arg ->
|
||||
.filter { it !in superAttributes && !it.static && (it.isVar || (it.isVal && superAttributesByName[it.name]?.hasNoVars() ?: true)) }
|
||||
.map { it.dynamicIfUnknownType(allTypes.keys) }
|
||||
.groupBy { it.signature }.reduceValues().values.forEach { arg ->
|
||||
renderAttributeDeclarationAsProperty(arg,
|
||||
override = arg.signature in superSignatures,
|
||||
open = iface.kind == GenerateDefinitionKind.CLASS && arg.isVal,
|
||||
@@ -157,7 +157,7 @@ fun Appendable.render(allTypes: Map<String, GenerateTraitOrClass>, typeNamesToUn
|
||||
level = 1
|
||||
)
|
||||
}
|
||||
iface.memberFunctions.filter { it !in superFunctions && !it.static }.map { it.dynamicIfUnknownType(allTypes.keySet()) }.groupBy { it.signature }.reduceValues(::betterFunction).values().forEach {
|
||||
iface.memberFunctions.filter { it !in superFunctions && !it.static }.map { it.dynamicIfUnknownType(allTypes.keys) }.groupBy { it.signature }.reduceValues(::betterFunction).values.forEach {
|
||||
renderFunctionDeclaration(it.fixRequiredArguments(iface.name), it.signature in superSignatures, commented = it.isCommented(iface.name))
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ fun Appendable.render(allTypes: Map<String, GenerateTraitOrClass>, typeNamesToUn
|
||||
appendln()
|
||||
|
||||
if (iface.generateBuilderFunction) {
|
||||
renderBuilderFunction(iface, allSuperTypes, allTypes.keySet())
|
||||
renderBuilderFunction(iface, allSuperTypes, allTypes.keys)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,15 +232,15 @@ fun Appendable.render(namespace: String, ifaces: List<GenerateTraitOrClass>, uni
|
||||
val declaredTypes = ifaces.toMap { it.name }
|
||||
|
||||
val allTypes = declaredTypes + unions.anonymousUnionsMap + unions.typedefsMarkersMap
|
||||
declaredTypes.values().filter { it.namespace == namespace }.forEach {
|
||||
declaredTypes.values.filter { it.namespace == namespace }.forEach {
|
||||
render(allTypes, unions.typeNamesToUnionsMap, it)
|
||||
}
|
||||
|
||||
unions.anonymousUnionsMap.values().filter { it.namespace == "" || it.namespace == namespace }.forEach {
|
||||
unions.anonymousUnionsMap.values.filter { it.namespace == "" || it.namespace == namespace }.forEach {
|
||||
render(allTypes, emptyMap(), it, markerAnnotation = true)
|
||||
}
|
||||
|
||||
unions.typedefsMarkersMap.values().filter { it.namespace == "" || it.namespace == namespace }.forEach {
|
||||
unions.typedefsMarkersMap.values.filter { it.namespace == "" || it.namespace == namespace }.forEach {
|
||||
render(allTypes, emptyMap(), it, markerAnnotation = true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ tailrec fun allSuperTypesImpl(roots: List<GenerateTraitOrClass>, all: Map<String
|
||||
}
|
||||
}
|
||||
|
||||
fun standardTypes() = typeMapper.values().map {it.dropNullable()}.toSet()
|
||||
fun standardTypes() = typeMapper.values.map {it.dropNullable()}.toSet()
|
||||
fun Type.dynamicIfUnknownType(allTypes: Set<String>, standardTypes: Set<Type> = standardTypes()): Type = when {
|
||||
this is DynamicType, this is UnitType -> this
|
||||
|
||||
@@ -110,7 +110,7 @@ private fun mapTypedef(repository: Repository, type: SimpleType): Type {
|
||||
private fun GenerateFunction?.allTypes() = if (this != null) sequenceOf(returnType) + arguments.asSequence().map { it.type } else emptySequence()
|
||||
|
||||
internal fun collectUnionTypes(allTypes: Map<String, GenerateTraitOrClass>) =
|
||||
allTypes.values().asSequence()
|
||||
allTypes.values.asSequence()
|
||||
.flatMap {
|
||||
it.secondaryConstructors.asSequence().flatMap { it.constructor.allTypes() } +
|
||||
sequenceOf(it.primaryConstructor).filterNotNull().flatMap { it.constructor.allTypes() } +
|
||||
|
||||
+2
-2
@@ -61,8 +61,8 @@ public class AnnotationListParseTest {
|
||||
|
||||
val actualAnnotations = StringBuilder()
|
||||
parsedAnnotations.forEach {
|
||||
for (element in it.getValue()) {
|
||||
actualAnnotations.append(it.getKey()).append(' ').append(element.classFqName)
|
||||
for (element in it.value) {
|
||||
actualAnnotations.append(it.key).append(' ').append(element.classFqName)
|
||||
when (element) {
|
||||
is AnnotatedMethodDescriptor -> actualAnnotations.append(' ').append(element.methodName)
|
||||
is AnnotatedFieldDescriptor -> actualAnnotations.append(' ').append(element.fieldName)
|
||||
|
||||
+1
-1
@@ -96,7 +96,7 @@ private fun Project.createKotlinAfterJavaTask(
|
||||
}
|
||||
|
||||
getAllTasks(false)
|
||||
.flatMap { it.getValue() }
|
||||
.flatMap { it.value }
|
||||
.filter { javaTask in it.taskDependencies.getDependencies(it) }
|
||||
.forEach { it.dependsOn(kotlinAfterJavaTask) }
|
||||
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ public class ThreadTracker {
|
||||
val log = Logging.getLogger(this.javaClass)
|
||||
private var before: Collection<Thread>? = getThreads()
|
||||
|
||||
private fun getThreads(): Collection<Thread> = Thread.getAllStackTraces().keySet()
|
||||
private fun getThreads(): Collection<Thread> = Thread.getAllStackTraces().keys
|
||||
|
||||
public fun checkThreadLeak(gradle: Gradle?) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user