Sort result ranges in SMAP class
This commit is contained in:
@@ -901,7 +901,7 @@ public class InlineCodegen extends CallGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static SourceMapper createNestedSourceMapper(@NotNull SMAPAndMethodNode nodeAndSmap, @NotNull SourceMapper parent) {
|
public static SourceMapper createNestedSourceMapper(@NotNull SMAPAndMethodNode nodeAndSmap, @NotNull SourceMapper parent) {
|
||||||
return new NestedSourceMapper(parent, nodeAndSmap.getRanges(), nodeAndSmap.getClassSMAP().getSourceInfo());
|
return new NestedSourceMapper(parent, nodeAndSmap.getSortedRanges(), nodeAndSmap.getClassSMAP().getSourceInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void reportIncrementalInfo(
|
static void reportIncrementalInfo(
|
||||||
|
|||||||
@@ -96,7 +96,8 @@ open class NestedSourceMapper(
|
|||||||
if (mappedLineNumber > 0) {
|
if (mappedLineNumber > 0) {
|
||||||
return mappedLineNumber
|
return mappedLineNumber
|
||||||
} else {
|
} else {
|
||||||
val rangeForMapping = if (lastVisitedRange?.contains(lineNumber) ?: false) lastVisitedRange!! else findMappingIfExists(lineNumber)!!
|
val rangeForMapping = (if (lastVisitedRange?.contains(lineNumber) ?: false) lastVisitedRange!! else findMappingIfExists(lineNumber))
|
||||||
|
?: error("Can't find range to map line $lineNumber in ${sourceInfo.source}:${sourceInfo.pathOrCleanFQN}")
|
||||||
val sourceLineNumber = rangeForMapping.mapDestToSource(lineNumber)
|
val sourceLineNumber = rangeForMapping.mapDestToSource(lineNumber)
|
||||||
val newLineNumber = parent.mapLineNumber(sourceLineNumber, rangeForMapping.parent!!.name, rangeForMapping.parent!!.path)
|
val newLineNumber = parent.mapLineNumber(sourceLineNumber, rangeForMapping.parent!!.name, rangeForMapping.parent!!.path)
|
||||||
if (newLineNumber > 0) {
|
if (newLineNumber > 0) {
|
||||||
@@ -118,10 +119,10 @@ open class NestedSourceMapper(
|
|||||||
|
|
||||||
open class InlineLambdaSourceMapper(
|
open class InlineLambdaSourceMapper(
|
||||||
parent: SourceMapper, smap: SMAPAndMethodNode
|
parent: SourceMapper, smap: SMAPAndMethodNode
|
||||||
) : NestedSourceMapper(parent, smap.ranges, smap.classSMAP.sourceInfo) {
|
) : NestedSourceMapper(parent, smap.sortedRanges, smap.classSMAP.sourceInfo) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
assert(smap.ranges.isNotEmpty()) {
|
assert(ranges.isNotEmpty()) {
|
||||||
"Mapping ranges should be presented in inline lambda: ${smap.node}"
|
"Mapping ranges should be presented in inline lambda: ${smap.node}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import java.util.*
|
|||||||
|
|
||||||
//TODO comment
|
//TODO comment
|
||||||
class SMAPAndMethodNode(val node: MethodNode, val classSMAP: SMAP) {
|
class SMAPAndMethodNode(val node: MethodNode, val classSMAP: SMAP) {
|
||||||
val ranges = createLineNumberSequence(node, classSMAP).map { it.mapper }.distinct().toList()
|
val sortedRanges = createLineNumberSequence(node, classSMAP).map { it.mapper }.distinct().toList().sortedWith(RangeMapping.Comparator)
|
||||||
|
|
||||||
fun copyWithNewNode(newMethodNode: MethodNode) = SMAPAndMethodNode(newMethodNode, classSMAP)
|
fun copyWithNewNode(newMethodNode: MethodNode) = SMAPAndMethodNode(newMethodNode, classSMAP)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user