Support mapNotNull intermediate operation
This commit is contained in:
committed by
Yan Zhulanow
parent
eaee6697f2
commit
85d83309ae
+3
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.debugger.streams.kotlin.lib.sequence
|
||||
|
||||
import com.intellij.debugger.streams.kotlin.resolve.MapNotNullResolver
|
||||
import com.intellij.debugger.streams.lib.IntermediateOperation
|
||||
import com.intellij.debugger.streams.lib.impl.*
|
||||
import com.intellij.debugger.streams.resolve.AppendResolver
|
||||
@@ -30,6 +31,8 @@ class KotlinSequencesSupport : LibrarySupportBase() {
|
||||
addIntermediateOperationsSupport(ConcatOperation("plusElement", AppendResolver()))
|
||||
|
||||
addIntermediateOperationsSupport(OrderBasedOperation("zipWithNext", PairMapResolver()))
|
||||
|
||||
addIntermediateOperationsSupport(OrderBasedOperation("mapNotNull", MapNotNullResolver()))
|
||||
}
|
||||
|
||||
private fun filterOperations(vararg names: String): Array<IntermediateOperation> =
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.debugger.streams.kotlin.resolve
|
||||
|
||||
import com.intellij.debugger.streams.resolve.ValuesOrderResolver
|
||||
import com.intellij.debugger.streams.trace.TraceElement
|
||||
import com.intellij.debugger.streams.trace.TraceInfo
|
||||
|
||||
/**
|
||||
* @author Vitaliy.Bibaev
|
||||
*/
|
||||
class MapNotNullResolver : ValuesOrderResolver {
|
||||
override fun resolve(info: TraceInfo): ValuesOrderResolver.Result {
|
||||
val before = info.valuesOrderBefore
|
||||
val after = info.valuesOrderAfter
|
||||
|
||||
val invertedOrder = mutableMapOf<Int, Int>()
|
||||
val beforeTimes = before.keys.sorted().toIntArray()
|
||||
val afterTimes = after.keys.sorted().toIntArray()
|
||||
var beforeIndex = 0
|
||||
for (afterTime in afterTimes) {
|
||||
while (beforeIndex < beforeTimes.size && afterTime > beforeTimes[beforeIndex]) beforeIndex += 1
|
||||
val beforeTime = beforeTimes[beforeIndex - 1]
|
||||
if (beforeTime < afterTime) {
|
||||
invertedOrder[afterTime] = beforeTime
|
||||
}
|
||||
}
|
||||
|
||||
val direct = mutableMapOf<TraceElement, List<TraceElement>>()
|
||||
val reverse = mutableMapOf<TraceElement, List<TraceElement>>()
|
||||
|
||||
for ((afterTime, beforeTime) in invertedOrder) {
|
||||
val beforeElement = before.getValue(beforeTime)
|
||||
val afterElement = after.getValue(afterTime)
|
||||
direct[beforeElement] = listOf(afterElement)
|
||||
reverse[afterElement] = listOf(beforeElement)
|
||||
}
|
||||
|
||||
return ValuesOrderResolver.Result.of(direct, reverse)
|
||||
}
|
||||
}
|
||||
@@ -13,21 +13,19 @@ toList
|
||||
after: nothing
|
||||
mappings for mapNotNull
|
||||
direct:
|
||||
1 -> nothing
|
||||
1 -> 2
|
||||
3 -> nothing
|
||||
4 -> nothing
|
||||
5 -> nothing
|
||||
5 -> 6
|
||||
reverse:
|
||||
nothing <- 2
|
||||
nothing <- 6
|
||||
1 <- 2
|
||||
5 <- 6
|
||||
mappings for toList
|
||||
direct:
|
||||
2 -> nothing
|
||||
6 -> nothing
|
||||
reverse:
|
||||
empty
|
||||
|
||||
WRONG! Support will be implemented later
|
||||
Disconnected from the target VM
|
||||
|
||||
Process finished with exit code 0
|
||||
|
||||
Reference in New Issue
Block a user