diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 23f5f1369..5d060ea59 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,7 +8,7 @@ guava = "33.0.0-jre" stitch = "0.6.2" tiny-remapper = "0.10.4" access-widener = "2.1.0" -mapping-io = "0.6.1" +mapping-io = "0.7.0" lorenz-tiny = "4.0.2" mercury = "0.4.2" loom-native = "0.2.0" diff --git a/src/main/java/net/fabricmc/loom/configuration/providers/mappings/tiny/MappingsMerger.java b/src/main/java/net/fabricmc/loom/configuration/providers/mappings/tiny/MappingsMerger.java index 5827a437d..2b83af30b 100644 --- a/src/main/java/net/fabricmc/loom/configuration/providers/mappings/tiny/MappingsMerger.java +++ b/src/main/java/net/fabricmc/loom/configuration/providers/mappings/tiny/MappingsMerger.java @@ -29,9 +29,7 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; -import java.util.Arrays; import java.util.Map; -import java.util.regex.Pattern; import com.google.common.base.Stopwatch; import org.jetbrains.annotations.VisibleForTesting; @@ -42,9 +40,9 @@ import net.fabricmc.loom.configuration.providers.mappings.IntermediateMappingsService; import net.fabricmc.loom.configuration.providers.minecraft.MinecraftProvider; import net.fabricmc.mappingio.adapter.MappingSourceNsSwitch; +import net.fabricmc.mappingio.adapter.OuterClassNamePropagator; import net.fabricmc.mappingio.format.tiny.Tiny2FileReader; import net.fabricmc.mappingio.format.tiny.Tiny2FileWriter; -import net.fabricmc.mappingio.tree.MappingTree; import net.fabricmc.mappingio.tree.MemoryMappingTree; public final class MappingsMerger { @@ -77,10 +75,9 @@ public static void mergeAndSaveMappings(Path from, Path out, IntermediateMapping MappingSourceNsSwitch nsSwitch = new MappingSourceNsSwitch(nsCompleter, MappingsNamespace.OFFICIAL.toString()); intermediaryTree.accept(nsSwitch); - inheritMappedNamesOfEnclosingClasses(officialTree); - try (var writer = new Tiny2FileWriter(Files.newBufferedWriter(out, StandardCharsets.UTF_8), false)) { - officialTree.accept(writer); + var classNamePropagator = new OuterClassNamePropagator(writer); + officialTree.accept(classNamePropagator); } } @@ -105,38 +102,4 @@ public static void legacyMergeAndSaveMappings(Path from, Path out, IntermediateM officialTree.accept(writer); } } - - /** - * Searches the mapping tree for inner classes with no mapped name, whose enclosing classes have mapped names. - * Currently, Yarn does not export mappings for these inner classes. - */ - private static void inheritMappedNamesOfEnclosingClasses(MemoryMappingTree tree) { - int intermediaryIdx = tree.getNamespaceId("intermediary"); - int namedIdx = tree.getNamespaceId("named"); - - // The tree does not have an index by intermediary names by default - tree.setIndexByDstNames(true); - - for (MappingTree.ClassMapping classEntry : tree.getClasses()) { - String intermediaryName = classEntry.getDstName(intermediaryIdx); - String namedName = classEntry.getDstName(namedIdx); - - if (intermediaryName.equals(namedName) && intermediaryName.contains("$")) { - String[] path = intermediaryName.split(Pattern.quote("$")); - int parts = path.length; - - for (int i = parts - 2; i >= 0; i--) { - String currentPath = String.join("$", Arrays.copyOfRange(path, 0, i + 1)); - String namedParentClass = tree.mapClassName(currentPath, intermediaryIdx, namedIdx); - - if (!namedParentClass.equals(currentPath)) { - classEntry.setDstName(namedParentClass - + "$" + String.join("$", Arrays.copyOfRange(path, i + 1, path.length)), - namedIdx); - break; - } - } - } - } - } }