Replace sort with sorted.

This commit is contained in:
Ilya Gorbunov
2015-09-30 21:27:31 +03:00
parent 389ea1b230
commit 37a0347669
50 changed files with 76 additions and 75 deletions
@@ -45,8 +45,8 @@ public object CodegenUtilKt {
return descriptor.getDefaultType().getMemberScope().getDescriptors().asSequence()
.filterIsInstance<CallableMemberDescriptor>()
.filter { it.getKind() == CallableMemberDescriptor.Kind.DELEGATION }
.toList()
.sortBy(MemberComparator.INSTANCE as Comparator<CallableMemberDescriptor>) // Workaround for KT-6030
.asIterable()
.sortedWith(MemberComparator.INSTANCE)
.keysToMapExceptNulls {
delegatingMember ->
@@ -243,7 +243,7 @@ class SMAP(val fileMappings: List<FileMapping>) {
val default: FileMapping
get() = fileMappings.first()
val intervals = fileMappings.flatMap { it.lineMappings }.sortBy(RangeMapping.Comparator)
val intervals = fileMappings.flatMap { it.lineMappings }.sortedWith(RangeMapping.Comparator)
val sourceInfo: SourceInfo
init {
@@ -131,7 +131,7 @@ public class KotlinCoreEnvironment private constructor(
message ->
report(ERROR, message)
}))
sourceFiles.sortBy(object : Comparator<JetFile> {
sourceFiles.sortedWith(object : Comparator<JetFile> {
override fun compare(o1: JetFile, o2: JetFile): Int {
return o1.getVirtualFile().getPath().compareTo(o2.getVirtualFile().getPath(), ignoreCase = true)
}
@@ -91,7 +91,7 @@ public fun getExpectedTypePredicate(
val candidates = callee.getReferenceTargets(bindingContext)
.filterIsInstance<FunctionDescriptor>()
.sortBy { DescriptorRenderer.DEBUG_TEXT.render(it) }
.sortedBy { DescriptorRenderer.DEBUG_TEXT.render(it) }
if (candidates.isEmpty()) return null
val explicitReceiver = call.getExplicitReceiver()
@@ -106,9 +106,9 @@ public object Renderers {
public val AMBIGUOUS_CALLS: Renderer<Collection<ResolvedCall<*>>> = Renderer {
calls: Collection<ResolvedCall<*>> ->
calls
calls
.map { it.getResultingDescriptor() }
.sortBy(MemberComparator.INSTANCE)
.sortedWith(MemberComparator.INSTANCE)
.joinToString(separator = "\n", prefix = "\n") { DescriptorRenderer.FQ_NAMES_IN_TYPES.render(it) }
}
@@ -142,7 +142,7 @@ public fun <TElement : JetElement> createByPattern(pattern: String, vararg args:
.flatMap { it.value }
.map { it.range }
.filterNot { it.isEmpty() }
.sortBy { -it.getStartOffset() }
.sortedBy { -it.getStartOffset() }
// reformat whole text except for String arguments (as they can contain user's formatting to be preserved)
if (stringPlaceholderRanges.none()) {
@@ -40,7 +40,7 @@ public open class KotlinStubBaseImpl<T : JetElementImplStub<*>>(parent: StubElem
}
private fun renderPropertyValues(stubInterface: Class<out Any?>): List<String> {
return collectProperties(stubInterface).map { property -> renderProperty(property) }.filterNotNull().sort()
return collectProperties(stubInterface).map { property -> renderProperty(property) }.filterNotNull().sorted()
}
private fun collectProperties(stubInterface: Class<*>): Collection<Method> {
@@ -69,7 +69,7 @@ public abstract class AbstractPseudoValueTest : AbstractPseudocodeTest() {
.map { (it as? InstructionWithValue)?.outputValue }
.filterNotNull()
.filter { it.element == null }
.toSortedListBy { it.debugName }
.sortedBy { it.debugName }
val allValues = elementToValues.values() + unboundValues
if (allValues.isEmpty()) return
@@ -68,7 +68,7 @@ class LazyOperationsLog(
return groupedByOwner.map {
val (owner, records) = it
renderOwner(owner, records)
}.sortBy(stringSanitizer).join("\n").renumberObjects()
}.sortedBy(stringSanitizer).join("\n").renumberObjects()
}
/**
@@ -97,7 +97,7 @@ class LazyOperationsLog(
with (Printer(sb)) {
println(render(owner), " {")
indent {
records.map { renderRecord(it) }.sortBy(stringSanitizer).forEach {
records.map { renderRecord(it) }.sortedBy(stringSanitizer).forEach {
println(it)
}
}
@@ -58,6 +58,6 @@ private fun checkSorted(descriptors: Collection<DeclarationDescriptor>, declarat
UsefulTestCase.assertOrderedEquals(
"Members of $declaration should be sorted by serialization.",
descriptors,
descriptors.sortBy(MemberComparator.INSTANCE)
descriptors.sortedWith(MemberComparator.INSTANCE)
)
}