Removed redundant cache, small rename refactoring after removing
This commit is contained in:
@@ -78,7 +78,7 @@ open class NestedSourceMapper(
|
||||
else {
|
||||
val rangeMapping = ranges[index]
|
||||
parent!!.visitSource(rangeMapping.parent!!.name, rangeMapping.parent!!.path)
|
||||
parent!!.visitLineNumber(iv, rangeMapping.map(lineNumber), start)
|
||||
parent!!.visitLineNumber(iv, rangeMapping.mapDestToSource(lineNumber), start)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -345,10 +345,14 @@ data class RangeMapping(val source: Int, val dest: Int, var range: Int = 1) {
|
||||
return if (skip) true else dest <= destLine && destLine < dest + range
|
||||
}
|
||||
|
||||
fun map(destLine: Int): Int {
|
||||
fun mapDestToSource(destLine: Int): Int {
|
||||
return if (skip) -1 else source + (destLine - dest)
|
||||
}
|
||||
|
||||
fun mapSourceToDest(sourceLine: Int): Int {
|
||||
return if (skip) -1 else dest + (sourceLine - source)
|
||||
}
|
||||
|
||||
object Comparator : java.util.Comparator<RangeMapping> {
|
||||
override fun compare(o1: RangeMapping, o2: RangeMapping): Int {
|
||||
if (o1 == o2) return 0
|
||||
|
||||
@@ -41,7 +41,7 @@ open class NestedSourceMapper(
|
||||
iv.visitLineNumber(mappedLineNumber, start)
|
||||
} else {
|
||||
val findMappingIfExists = findMappingIfExists(lineNumber)!!
|
||||
val sourceLineNumber = findMappingIfExists.map(lineNumber)
|
||||
val sourceLineNumber = findMappingIfExists.mapDestToSource(lineNumber)
|
||||
val visitLineNumber = parent.visitLineNumber(iv, lineNumber, start, LineNumberToMap(lineNumber, sourceLineNumber, findMappingIfExists.parent!!.name, findMappingIfExists.parent!!.path))
|
||||
if (visitLineNumber > 0) {
|
||||
visited.put(lineNumber, visitLineNumber)
|
||||
@@ -150,7 +150,6 @@ open class DefaultSourceMapper @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
class RawFileMapping(val name: String, val path: String) {
|
||||
private val lineMappings = TIntIntHashMap()
|
||||
private val rangeMappings = arrayListOf<RangeMapping>()
|
||||
|
||||
private var lastMappedWithNewIndex = -1000
|
||||
@@ -163,29 +162,18 @@ class RawFileMapping(val name: String, val path: String) {
|
||||
}
|
||||
|
||||
fun initRange(start: Int, end: Int) {
|
||||
assert(lineMappings.isEmpty) { "initRange should only be called for empty mapping" }
|
||||
for (index in start..end) {
|
||||
lineMappings.put(index, index)
|
||||
}
|
||||
assert(rangeMappings.isEmpty()) { "initRange should only be called for empty mapping" }
|
||||
rangeMappings.add(RangeMapping(start, start, end - start + 1))
|
||||
lastMappedWithNewIndex = end
|
||||
}
|
||||
|
||||
fun mapLine(source: Int, currentIndex: Int, isLastMapped: Boolean): Int {
|
||||
var dest = lineMappings[source]
|
||||
if (dest == 0) { // line numbers are 1-based, so 0 is ok to indicate missing value
|
||||
dest = mapNewLineNumber(source, currentIndex, isLastMapped)
|
||||
}
|
||||
return dest
|
||||
}
|
||||
|
||||
fun mapNewLineNumber(source: Int, currentIndex: Int, isLastMapped: Boolean): Int {
|
||||
val dest: Int
|
||||
val rangeMapping: RangeMapping
|
||||
if (rangeMappings.isNotEmpty() && isLastMapped && couldFoldInRange(lastMappedWithNewIndex, source)) {
|
||||
rangeMapping = rangeMappings.last()
|
||||
rangeMapping.range += source - lastMappedWithNewIndex
|
||||
dest = lineMappings[lastMappedWithNewIndex] + source - lastMappedWithNewIndex
|
||||
dest = rangeMapping.mapSourceToDest(source)
|
||||
}
|
||||
else {
|
||||
dest = currentIndex + 1
|
||||
@@ -193,7 +181,6 @@ class RawFileMapping(val name: String, val path: String) {
|
||||
rangeMappings.add(rangeMapping)
|
||||
}
|
||||
|
||||
lineMappings.put(source, dest)
|
||||
lastMappedWithNewIndex = source
|
||||
return dest
|
||||
}
|
||||
@@ -201,10 +188,6 @@ class RawFileMapping(val name: String, val path: String) {
|
||||
fun mapNewInterval(source: Int, dest: Int, range: Int) {
|
||||
val rangeMapping = RangeMapping(source, dest, range)
|
||||
rangeMappings.add(rangeMapping)
|
||||
|
||||
(source..(source + range - 1)).forEach {
|
||||
lineMappings.put(source, dest)
|
||||
}
|
||||
}
|
||||
|
||||
private fun couldFoldInRange(first: Int, second: Int): Boolean {
|
||||
|
||||
@@ -122,7 +122,7 @@ class KotlinExceptionFilter(private val searchScope: GlobalSearchScope) : Filter
|
||||
|
||||
val newJvmName = JvmClassName.byInternalName(mappingInfo.path)
|
||||
val newSourceFile = DebuggerUtils.findSourceFileForClassIncludeLibrarySources(project, searchScope, newJvmName, mappingInfo.name) ?: return null
|
||||
return OpenFileHyperlinkInfo(project, newSourceFile.virtualFile, mappingInfo.getIntervalIfContains(line)!!.map(line) - 1)
|
||||
return OpenFileHyperlinkInfo(project, newSourceFile.virtualFile, mappingInfo.getIntervalIfContains(line)!!.mapDestToSource(line) - 1)
|
||||
}
|
||||
|
||||
private fun readDebugInfo(bytes: ByteArray): String? {
|
||||
|
||||
Reference in New Issue
Block a user