aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt')
-rw-r--r--src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
index a8d9f2a..c620c4c 100644
--- a/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
+++ b/src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
@@ -31,7 +31,7 @@ internal class PsiMapper(
) {
private val mixinMappings = mutableMapOf<String, ClassMapping<*, *>>()
private val errors = mutableListOf<Pair<Int, String>>()
- private val changes = TreeMap<TextRange, String>(Comparator.comparing<TextRange, Int> { it.startOffset })
+ private val changes = TreeMap<TextRange, String>(compareBy<TextRange> { it.startOffset }.thenBy { it.endOffset })
private fun error(at: PsiElement, message: String) {
val line = StringUtil.offsetToLineNumber(file.text, at.textOffset)
@@ -40,7 +40,13 @@ internal class PsiMapper(
private fun replace(e: PsiElement, with: String) = replace(e.textRange, with)
private fun replace(textRange: TextRange, with: String) {
- changes[textRange] = with
+ changes.compute(textRange) { _, replacement ->
+ if (replacement != null) {
+ replacement + with
+ } else {
+ with
+ }
+ }
}
private fun replaceIdentifier(parent: PsiElement, with: String) {