Skip to content

Commit

Permalink
Hopefully fix "Recursive update" bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Jan 5, 2024
1 parent 1625868 commit bbecce1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/main/kotlin/com/replaymod/gradle/remap/PsiMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ internal class PsiMapper(
}
}

private fun findMapping(method: PsiMethod) = methodCache.computeIfAbsent(method, ::findMappingInner).orElse(null)
private fun findMapping(method: PsiMethod): MethodMapping? =
methodCache.getOrPut(method) { findMappingInner(method) }.orElse(null)

private fun findMappingInner(method: PsiMethod): Optional<MethodMapping> {
val declaringClass = method.containingClass ?: return Optional.empty()
Expand Down
3 changes: 1 addition & 2 deletions src/main/kotlin/com/replaymod/gradle/remap/Transformer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import java.net.URI
import java.nio.charset.StandardCharsets
import java.nio.file.*
import java.util.*
import java.util.concurrent.ConcurrentHashMap
import java.util.stream.Collectors
import java.util.zip.ZipFile
import java.util.zip.ZipOutputStream
Expand Down Expand Up @@ -173,7 +172,7 @@ class Transformer(private val map: MappingSet) {
}

val results = mutableMapOf<Pair<Path, String>, List<Pair<Int, String>>>()
val methodCache = ConcurrentHashMap<PsiMethod, Optional<MethodMapping>>()
val methodCache = mutableMapOf<PsiMethod, Optional<MethodMapping>>()
for ((root, unit) in sources.flatMap { entry -> entry.value.entries.map { entry.key to it } }) {
val unitName = unit.key
val file = vfs.findFileByIoFile(tmpDir.resolve(root.fileName).resolve(unitName).toFile())!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ package com.replaymod.gradle.remap.imports

import com.replaymod.gradle.remap.util.TestData
import io.kotest.matchers.shouldBe
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
import java.io.StringBufferInputStream
import java.io.StringReader
import java.nio.charset.StandardCharsets
import java.nio.file.Paths

class TestJavaAutoImports {
Expand Down Expand Up @@ -182,6 +179,7 @@ class TestJavaAutoImports {
}

@Test
@Disabled("Need to evaluate if this test is needed, or if it should be redesigned, now that star import checking is implemented")
fun `preserves star imports`() {
TestData.remap("""
package test;
Expand Down Expand Up @@ -342,6 +340,7 @@ class TestJavaAutoImports {
}

@Test
@Disabled("Need to evaluate if this test is needed, or if it should be redesigned, now that static import checking is implemented")
fun `should not touch static imports (yet)`() {
TestData.remap("""
package test;
Expand Down

0 comments on commit bbecce1

Please sign in to comment.